More fp bug in egcs

Jim Wilson wilson@cygnus.com
Thu Apr 30 20:03:00 GMT 1998


I believe this is another bug in the same i386 code as my last patch.

The problem is that the only FP->DImode converstion instruction pops the
FP stack.  Normally we have both popping and non-popping versions of
instructions.  The x86 code handles this by aborting if we need to emit
the non-existent non-popping instruction.  However, this can't work all
of the time, because it assumes the optimizer always generates optimal
code.  That isn't safe.  And it is obviously not safe if we are compiling
without optimization.

In order to fix this, we need to emulate the missing instruction if gcc
needs to emit it.  The following patch does this.   If there is a better way
to do this, then let me know.

Thu Apr 30 19:28:16 1998  Jim Wilson  <wilson@cygnus.com>

	* i386.c (output_fix_trunc): Add code to emulate non-popping DImode
	case.

*** i386.c	Sun Feb 15 11:54:11 1998
--- /home/wilson/tmp/i386.c	Thu Apr 30 19:26:54 1998
*************** output_fix_trunc (insn, operands)
*** 3731,3738 ****
    int stack_top_dies = find_regno_note (insn, REG_DEAD, FIRST_STACK_REG) != 0;
    rtx xops[2];
  
!   if (! STACK_TOP_P (operands[1]) ||
!       (GET_MODE (operands[0]) == DImode && ! stack_top_dies))
      abort ();
  
    xops[0] = GEN_INT (12);
--- 3731,3737 ----
    int stack_top_dies = find_regno_note (insn, REG_DEAD, FIRST_STACK_REG) != 0;
    rtx xops[2];
  
!   if (! STACK_TOP_P (operands[1]))
      abort ();
  
    xops[0] = GEN_INT (12);
*************** output_fix_trunc (insn, operands)
*** 3750,3755 ****
--- 3749,3765 ----
      {
        if (stack_top_dies)
  	output_asm_insn (AS1 (fistp%z0,%0), operands);
+       else if (GET_MODE (operands[0]) == DImode && ! stack_top_dies)
+ 	{
+ 	  /* There is no DImode version of this without a stack pop, so
+ 	     we must emulate it.  It doesn't matter much what the second
+ 	     instruction is, because the value being pushed on the FP stack
+ 	     is not used except for the following stack popping store.
+ 	     This case can only happen without optimization, so it doesn't
+ 	     matter that it is inefficient.  */
+ 	  output_asm_insn (AS1 (fistp%z0,%0), operands);
+ 	  output_asm_insn (AS1 (fild%z0,%0), operands);
+ 	}
        else
  	output_asm_insn (AS1 (fist%z0,%0), operands);
      }



More information about the Gcc mailing list