david@EDDIE.MIT.EDU (12/15/89)
gcc version: 1.36
os version: Interactive 386/ix 1.0.6 (System V Rel 3.1)
the following code cause a core dump when compiled with "gcc -O"
main()
{
float f;
f = 0;
printf("%g, %g\n", f, f);
}
This is because the un-named instruction describing how to move a
double from a float register to the top of the stack does not take into
account the fact that popping from the 387 register stack invalidates
the contents of the register. I would guess that the same thing would
happen on a Sun 386 system. Here is a patch to fix the problem. It is
similar to the code in the other (named) insn's to check if the
register is still needed.
*** md Mon Dec 11 09:26:24 1989
--- config/i386.md Thu Dec 14 14:29:32 1989
***************
*** 390,396 ****
xops[2] = stack_pointer_rtx;
/* fp_pop_level--; */
output_asm_insn (AS2 (sub%L0,%1,%2), xops);
! output_asm_insn (\"fstp%S0 %0\", xops);
RET;
}
return \"push%L0 %1\";
--- 390,399 ----
xops[2] = stack_pointer_rtx;
/* fp_pop_level--; */
output_asm_insn (AS2 (sub%L0,%1,%2), xops);
! if (top_dead_p(insn))
! output_asm_insn (\"fstp%S0 %0\", xops);
! else
! output_asm_insn (\"fst%S0\", xops);
RET;
}
return \"push%L0 %1\";
***************
*** 426,432 ****
xops[2] = stack_pointer_rtx;
/* fp_pop_level--; */
output_asm_insn (AS2 (sub%L0,%1,%2), xops);
! output_asm_insn (\"fstp%Q0 %0\", xops);
RETCOM (pushdf);
}
else
--- 429,438 ----
xops[2] = stack_pointer_rtx;
/* fp_pop_level--; */
output_asm_insn (AS2 (sub%L0,%1,%2), xops);
! if (top_dead_p(insn))
! output_asm_insn (\"fstp%Q0 %0\", xops);
! else
! output_asm_insn (\"fst%Q0 %0\", xops);
RETCOM (pushdf);
}
else