------- Comment #7 from sje at cup dot hp dot com 2008-06-05 23:02 ------- I now think this is a register scheduling bug. If I use -fno-schedule-insns2 then the bug doesn't happen even with "-O2 fno-automatic -frename-registers".
The problem seems to be scheduling the assignment to TEMP2 and assigning TEMP2 to F(K). In the good code, in C201S I see the following instructions, in this order: addl r17 = @gprel(temp2.717#), gp - r17 is addr of temp2 stfd [r17] = f0 - zero out temp2 (p11) stfd [r17] = f10 - (maybe) put value (2.0) in temp2 ldfd f9 = [r17] - load temp2 add r16 = r34, r37 - r16 is addr of F(1) stfd [r16] = f9 - store temp2 in F(1) In the bad code (with instruction scheduling turned on) I see: addl r17 = @gprel(temp2.717#), gp - r17 is addr of temp2 add r16 = r34, r37 - r16 is addr of F(1) ldfd f9 = [r17] - load temp2 stfd [r17] = f0 - zero out temp2 stfd [r16] = f9 - store (old) temp2 in F(1) (p11) stfd [r17] = f10 - (maybe) put value (2.0) in temp2 The store into F(1) is done before we have put the correct value int temp2. I don't understand how instruction scheduling could be this broken. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35658