wilson@vangogh.Berkeley.EDU (James E. Wilson) (01/28/89)
[gcc v1.32] The use of "-O -ffloat-store" on a Sun3 can cause comparisons against zero to fail. The program included below demonstrates this bug. The problem is that output_move_double() requires at least two instructions, and hence the condition codes will not be valid afterwards. Gcc believes that the cc are valid, though, and proceeds to delete the following floating point test instruction, as it considers it unneccesary. I solved the problem by always invalidating the condition codes when output_move_double() is called. I have included a context diff below. This seems to work, although I am not sure if this is the best solution. Also, a similar fix may be necessary for the other architectures supported by gcc, someone should check. *** orig.output-m68k.c Fri Jan 27 15:39:40 1989 --- output-m68k.c Fri Jan 27 19:00:44 1989 *************** *** 90,95 **** --- 90,99 ---- rtx latehalf[2]; rtx addreg0 = 0, addreg1 = 0; + /* invalidate the condition codes, since it will take at least two + instructions to move the double value */ + CC_STATUS_INIT; + /* First classify both operands. */ if (REG_P (operands[0])) Script started on Fri Jan 27 19:37:05 1989 proxima<1> proxima<1>cat tmp.c /* * With both -O and -ffloat-store, gcc v1.32 on a Sun3 will print "1 == 0???". */ main(void) { double x = (double)1.0; if (x == (double)0) (void)printf("%.0f == 0???\n",x); else (void)printf("OK\n",x); (void)exit(0); } proxima<2> proxima<2>./gcc -O -S -ffloat-store tmp.c 0.3u 1.2s 0:06 23% 80+40k 16+11io 73pf+0w proxima<3> proxima<3>cat tmp.s #NO_APP gcc_compiled.: .text LC0: .ascii "%.0f == 0???\12\0" LC1: .ascii "OK\12\0" .even .globl _main _main: link a6,#-8 movel #1072693248,a6@(-8) clrl a6@(-4) jne L2 movel a6@(-4),sp@- movel a6@(-8),sp@- pea LC0 jra L4 L2: movel a6@(-4),sp@- movel a6@(-8),sp@- pea LC1 L4: jbsr _printf addw #12,sp clrl sp@- jbsr _exit unlk a6 rts proxima<4> proxima<4>./gcc tmp.s 0.6u 1.9s 0:06 41% 16+24k 52+8io 0pf+0w proxima<5>a.out 1 == 0??? proxima<6> proxima<6>exit proxima<7> script done on Fri Jan 27 19:37:51 1989 Jim Wilson | For rain it hath a friendly sound Internet: wilson@ernie.Berkeley.EDU | To one who's six feet under ground; Usenet: ...!ucbvax!ucbernie!wilson | And scarce the friendly voice or face, | A grave is such a quiet place.