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 PR optimization/8366 (Sparc)


Hi,

There is a testsuite failure on sparc-sun-solaris2.7 in 64-bit mode: the 
compiler emits wrong code for gcc.c-torture/execute/loop-2d.c with -O -fpic.

The combine pass turns

(insn 92 91 93 (set (reg/f:DI 122)
        (reg/f:DI 124)) -1 (insn_list 91 (nil))
    (expr_list:REG_DEAD (reg/f:DI 124)
        (expr_list:REG_EQUAL (symbol_ref:DI ("a"))
            (nil))))

(insn 93 92 26 (set (reg:SI 120)
        (subreg:SI (reg/f:DI 122) 4)) -1 (insn_list 92 (nil))
    (expr_list:REG_DEAD (reg/f:DI 122)
        (nil)))

into

(insn 93 92 26 (set (reg:SI 120)
        (mem/u:SI (plus:DI (reg:DI 23 %l7)
                (const:DI (plus:DI (symbol_ref:DI ("a"))
                        (const_int 4 [0x4])))) [0 S4 A32])) 51 {*movsi_insn} 
(nil)


The latter insn is emitted by GCC as:
 
   ld  [%l7+a+4], %g4

but assembled by the Sun assembler as:

   ld  [%l7+a], %g4

which is certainly not what we want :-)


The fix is to teach GO_IF_LEGITIMATE_ADDRESS not to accept the faulty address 
form (pic_offset_table_rtx + CONST). This is technically not a regression 
according to Kaveh, but the fix is safe enough to be applied everywhere.

Thanks to Kaveh for bootstrapping/regtesting the patch on the 3.2 and 3.3 
branches on his monstrously fast Sparc box :-)

Ok for mainline and 3.3? Ok for 3.2 branch too?

-- 
Eric Botcazou


2003-03-09  Eric Botcazou  <ebotcazou at libertysurf dot fr>

	PR optimization/8366
	* config/sparc/sparc.h (GO_IF_LEGITIMATE_ADDRESS): Forbid
	(pic_offset_table_rtx + CONST) addressing mode.
Index: config/sparc/sparc.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sparc/sparc.h,v
retrieving revision 1.161.2.27
diff -u -p -r1.161.2.27 sparc.h
--- config/sparc/sparc.h	24 Jun 2002 16:50:44 -0000	1.161.2.27
+++ config/sparc/sparc.h	8 Mar 2003 11:17:37 -0000
@@ -2236,6 +2236,7 @@ do {									\
 		   && GET_CODE (op1) != REG		\
 		   && GET_CODE (op1) != LO_SUM		\
 		   && GET_CODE (op1) != MEM		\
+		   && GET_CODE (op1) != CONST		\
 		   && (GET_CODE (op1) != CONST_INT	\
 		       || SMALL_INT (op1)))		\
 	    goto ADDR;					\

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