On 26/11/13 12:29, Yufeng Zhang wrote:
> Hi,
> 
> arm_legitimize_address forces immediates in PLUS to be in REG for no 
> good reason.  This patch changes it not to do this.
> 
> With the immediate constants directly available in the RTL, it helps the 
> expand more effectively to fold and re-associate the immediates.
> 
> The change also helps the following if condition in 
> arm_legitimize_address to have chance to be true:
> 
>        if (ARM_BASE_REGISTER_RTX_P (xop0)
>            && CONST_INT_P (xop1))
>          {
> 
> The -fdump-rtl-expand diff for the added test case is:
> 
>   ;; Generating RTL for gimple basic block 2
> @@ -32,53 +32,50 @@
>        (nil))
>   (note 4 3 7 2 NOTE_INSN_FUNCTION_BEG)
>   (insn 7 4 8 2 (set (reg:SI 116)
> -        (const_int 4000 [0xfa0]))
> -     (nil))
> -(insn 8 7 9 2 (set (reg:SI 117)
>           (reg/v:SI 115 [ i ]))
>        (nil))
> [snip]
> -(insn 16 15 17 2 (set (reg/f:SI 124)
> -        (plus:SI (reg:SI 123)
> -            (reg:SI 116)))
> +(insn 15 14 16 2 (set (reg/f:SI 123)
> +        (plus:SI (reg:SI 122)
> +            (const_int 4000 [0xfa0])))
>        (nil))
> -(insn 17 16 18 2 (set (reg:SI 125)
> +(insn 16 15 17 2 (set (reg:SI 124)
>           (const_int 1 [0x1]))
>        (nil))
> -(insn 18 17 0 2 (set (mem:SI (plus:SI (mult:SI (reg/v:SI 115 [ i ])
> +(insn 17 16 0 2 (set (mem:SI (plus:SI (mult:SI (reg/v:SI 115 [ i ])
>                       (const_int 4 [0x4]))
> -                (reg/f:SI 124)) [2 *_6 S4 A32])
> -        (reg:SI 125))
> +                (reg/f:SI 123)) [2 *_6 S4 A32])
> +        (reg:SI 124))
>        (nil))
> 
> Passed bootstrapping on cortex-a15 and regtest on arm-none-eabi.
> 
> OK for the trunk?
> 
> Thanks,
> Yufeng
> 
> 
> gcc/
> 
>       * config/arm/arm.c (arm_legitimize_address): Check xop1 is not
>       a constant immediate before force_reg.
> 
> gcc/testsuite/
> 
>       * gcc.target/arm/20131120.c: New test.
> 
> 

OK.

R.


Reply via email to