[PATCH] Fix PR optimization/8366 (Sparc)

Eric Botcazou ebotcazou@libertysurf.fr
Sun Mar 9 08:17:00 GMT 2003


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@libertysurf.fr>

	PR optimization/8366
	* config/sparc/sparc.h (GO_IF_LEGITIMATE_ADDRESS): Forbid
	(pic_offset_table_rtx + CONST) addressing mode.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr8366.diff
Type: text/x-diff
Size: 598 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20030309/5b614c75/attachment.bin>


More information about the Gcc-patches mailing list