This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix trunc_int_for_mode in eliminate_regs_in_insn (PR target/38208)


Hi!

gcc.c-torture/compile/20080806-1.c now fails on i386 at -O3
-fomit-frame-pointer -funroll-loops, because gas warns about
addw $65544, %dx.  My memcpy optimization patch just changed what comes up
from the tree optimizers, but it is correct.  But when
eliminate_regs_in_insn is called on:

 (insn:HI 6 5 7 2 20080806-1.c:16 (parallel [
             (set (reg:HI 58 [ pretmp.42 ])
                 (plus:HI (subreg:HI (reg/f:SI 20 frame) 0)
                     (const_int 136 [0x88])))
             (clobber (reg:CC 17 flags))
         ]) 293 {*addhi_1_lea} (expr_list:REG_UNUSED (reg:CC 17 flags)
         (nil)))

and wants to eliminate (reg:SI 20 frame) for
(plus:SI (reg:SI sp) (const_int 65408 [0xff80]))
it adds 136 to 0xff80, but truncates it for SImode (GET_MODE (reg))
instead of the mode in which the PLUS is performed (HImode,
GET_MODE (plus_cst_src)).  So
             (set (reg:HI 1 dx [orig:58 pretmp.42 ] [58])
                 (plus:HI (reg:HI 1 dx [orig:58 pretmp.42 ] [58])
                     (const_int 65544 [0x10008])))
is created, which is of course invalid.

The following patch fixes that, bootstrapped/regtested on x86_64-linux,
ok for trunk?

2008-11-21  Jakub Jelinek  <jakub@redhat.com>

	PR target/38208
	* reload1.c (eliminate_regs_in_insn): For trunc_int_for_mode use
	mode of PLUS, not mode of the eliminated register.

--- gcc/reload1.c.jj	2008-10-14 13:58:50.000000000 +0200
+++ gcc/reload1.c	2008-11-21 09:20:25.000000000 +0100
@@ -1,6 +1,6 @@
 /* Reload pseudo regs into hard regs for insns that require hard regs.
    Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -3299,7 +3299,7 @@ eliminate_regs_in_insn (rtx insn, int re
 	  {
 	    rtx to_rtx = ep->to_rtx;
 	    offset += ep->offset;
-	    offset = trunc_int_for_mode (offset, GET_MODE (reg));
+	    offset = trunc_int_for_mode (offset, GET_MODE (plus_cst_src));
 
 	    if (GET_CODE (XEXP (plus_cst_src, 0)) == SUBREG)
 	      to_rtx = gen_lowpart (GET_MODE (XEXP (plus_cst_src, 0)),

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]