Patch to fix crash in i386 xfmode pattern

Jan Hubicka hubicka@atrey.karlin.mff.cuni.cz
Thu Nov 11 02:50:00 GMT 1999


Hi
When constant needs to be loaded into XFmode integer registers, reload
realizes, that with current movxf_1 constraints it is impossible and
for some purpose attempts to load constant into FP register and then do
FP register -> integer register move. This results in incorrect insn and
crash.

While I wasn't able to track down the reload problem (someone who
onderstands it will surely do it much sooner than I can) I've added
the constant support to movxf_1 splitters. This is important anyway,
optimizes code (especially loading constants into memory) and makes
possible to compile XaoS with recent snapshots.

Crash can be seen on:
main()
{
  long double a=1;
  asm(""::"r"(a));
}

Honza

Wed Oct 10 23:17:12 CET 1999  Jan Hubicka  <hubicka@freesoft.cz>
	* i386.c (split_xf): Handle constants.
	* i386.md (movxf_1): Allow constant->integer reg move.
	(movxf_1 splitter): Likewise.

*** i386.c.old	Wed Nov 10 23:16:41 1999
--- i386.c	Wed Nov 10 22:01:31 1999
*************** split_xf (orig, out)
*** 3151,3156 ****
--- 3151,3167 ----
        out[1] = gen_rtx_REG (SImode, regno + 1);
        out[2] = gen_rtx_REG (SImode, regno + 2);
      }
+   else if (CONSTANT_P (orig))
+     {
+       REAL_VALUE_TYPE r;
+       long l[3];
+ 
+       REAL_VALUE_FROM_CONST_DOUBLE (r, orig);
+       REAL_VALUE_TO_TARGET_LONG_DOUBLE (r, l);
+       out[0] = GEN_INT (l[0]);
+       out[1] = GEN_INT (l[1]);
+       out[2] = GEN_INT (l[2]);
+     }
    else
      {
        out[0] = change_address (orig, SImode, NULL_RTX);
*** i386.md.old	Wed Nov 10 21:58:00 1999
--- i386.md	Wed Nov 10 22:07:24 1999
***************
*** 2006,2012 ****
  
  (define_insn "*movxf_1"
    [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,*&r,o")
! 	(match_operand:XF 1 "general_operand" "fm,f,G,*ro,*r"))]
    ""
    "*
  {
--- 2006,2012 ----
  
  (define_insn "*movxf_1"
    [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,*&r,o")
! 	(match_operand:XF 1 "general_operand" "fm,f,G,*rFo,*rF"))]
    ""
    "*
  {
***************
*** 2048,2056 ****
  
  (define_split
    [(set (match_operand:XF 0 "nonimmediate_operand" "")
! 	(match_operand:XF 1 "nonimmediate_operand" ""))]
!   "(REG_P (operands[0]) && ! FP_REGNO_P (REGNO (operands[0])))
!    || (REG_P (operands[1]) && ! FP_REGNO_P (REGNO (operands[1])))"
    [(set (match_dup 0) (match_dup 3))
     (set (match_dup 1) (match_dup 4))
     (set (match_dup 2) (match_dup 5))]
--- 2048,2056 ----
  
  (define_split
    [(set (match_operand:XF 0 "nonimmediate_operand" "")
! 	(match_operand:XF 1 "general_operand" ""))]
!   "(! REG_P (operands[0]) || ! FP_REGNO_P (REGNO (operands[0])))
!    && (! REG_P (operands[1]) || ! FP_REGNO_P (REGNO (operands[1])))"
    [(set (match_dup 0) (match_dup 3))
     (set (match_dup 1) (match_dup 4))
     (set (match_dup 2) (match_dup 5))]


More information about the Gcc-patches mailing list