Path: utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!GANG-OF-FOUR.STANFORD.EDU!weening From: weening@GANG-OF-FOUR.STANFORD.EDU (Joe Weening) Newsgroups: gnu.gcc.bug Subject: Redundant test instructions in GCC 1.34 on m68k Message-ID: <8903230625.AA03410@Gang-of-Four.Stanford.EDU> Date: 23 Mar 89 06:25:29 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 72 I'm trying to figure out why the following program produces the assem- bly code shown below, in GCC 1.34 on a Sun-2 running Sun OS 4.0. -------------------------------------------------- Source code: int i = 4; int j = -5; main () { if (i+j <= 0) printf ("negative\n"); else printf ("non-negative\n"); } -------------------------------------------------- Assembly code: #NO_APP gcc_compiled.: .globl _i .data .even _i: .long 4 .globl _j .even _j: .long -5 .text LC0: .ascii "negative\12\0" LC1: .ascii "non-negative\12\0" .even .globl _main _main: link a6,#0 movel _i,d0 addl _j,d0 tstl d0 jgt L2 pea LC0 jra L4 L2: pea LC1 L4: jbsr _printf unlk a6 rts -------------------------------------------------- The "tstl" instruction after the "addl" doesn't seem to be necessary, because the addl will set the condition codes. The above example arose as I was trying to answer a different question, which is how m68k.md can get away with giving OUTPUT_JUMP a third argument of 0 in patterns such as: (define_insn "bgt" [(set (pc) (if_then_else (gt (cc0) (const_int 0)) (label_ref (match_operand 0 "" "")) (pc)))] "" "* #ifdef MOTOROLA OUTPUT_JUMP (\"jbgt %l0\", \"fbgt %l0\", 0); #else OUTPUT_JUMP (\"jgt %l0\", \"fjgt %l0\", 0); #endif ") Isn't the third argument sometimes going to be used?