diff mbox

Fix up ix86_avoid_lea_for_addr (PR target/59880)

Message ID CAFULd4a7iYuSeT9-+Jucovu1hi-rJLp3zqb_LTSQYrBuP21X+g@mail.gmail.com
State New
Headers show

Commit Message

Uros Bizjak Jan. 20, 2014, 12:12 p.m. UTC
On Mon, Jan 20, 2014 at 10:11 AM, Uros Bizjak <ubizjak@gmail.com> wrote:

>> As mentioned in the PR or even in the comment below, ix86_decompose_address
>> sometimes sets parts.base to some REG and parts.disp to const0_rtx, even
>> when the operands aren't of a lea insn, but normal or zero extending mov.
>>
>> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
>> trunk?
>>
>> 2014-01-20  Jakub Jelinek  <jakub@redhat.com>
>>
>>         PR target/59880
>>         * config/i386/i386.c (ix86_avoid_lea_for_addr): Return false
>>         if operands[1] is a REG or ZERO_EXTEND of a REG.
>>
>>         * gcc.target/i386/pr59880.c: New test.

> This is OK for mainline, I will take care for a backport (together
> with 59379) to other release branches.

There are some additional zero-extension insns (SUBREG and AND, all
conveniently detected in SImode_address_operand predicate) that should
be considered here. I am testing following patch:


Uros.

Comments

Uros Bizjak Jan. 20, 2014, 6 p.m. UTC | #1
On Mon, Jan 20, 2014 at 1:12 PM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Mon, Jan 20, 2014 at 10:11 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
>
>>> As mentioned in the PR or even in the comment below, ix86_decompose_address
>>> sometimes sets parts.base to some REG and parts.disp to const0_rtx, even
>>> when the operands aren't of a lea insn, but normal or zero extending mov.
>>>
>>> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
>>> trunk?
>>>
>>> 2014-01-20  Jakub Jelinek  <jakub@redhat.com>
>>>
>>>         PR target/59880
>>>         * config/i386/i386.c (ix86_avoid_lea_for_addr): Return false
>>>         if operands[1] is a REG or ZERO_EXTEND of a REG.
>>>
>>>         * gcc.target/i386/pr59880.c: New test.
>
>> This is OK for mainline, I will take care for a backport (together
>> with 59379) to other release branches.
>
> There are some additional zero-extension insns (SUBREG and AND, all
> conveniently detected in SImode_address_operand predicate) that should
> be considered here. I am testing following patch:

Tested on x86_64-pc-linux-gnu and committed to mainline with following
ChangeLog:

2014-01-20  Uros Bizjak  <ubizjak@gmail.com>

    * config/i386/i386.c (ix86_avoid_lea_for_addr): Return false
    for SImode_address_operand operands, having only a REG argument.

> Index: config/i386/i386.c
> ===================================================================
> --- config/i386/i386.c  (revision 206792)
> +++ config/i386/i386.c  (working copy)
> @@ -18160,13 +18160,12 @@ ix86_avoid_lea_for_addr (rtx insn, rtx operands[])
>      return false;
>
>    /* The "at least two components" test below might not catch simple
> -     *mov[sd]i_internal or *zero_extendsidi2 insns if parts.base is
> -     non-NULL and parts.disp is const0_rtx as the only components in
> -     the address, e.g. if the register is %rbp or %r13.  As this
> -     test is much cheaper and moves or zero extensions are the common
> -     case, do this check first.  */
> +     move or zero extension insns if parts.base is non-NULL and parts.disp
> +     is const0_rtx as the only components in the address, e.g. if the
> +     register is %rbp or %r13.  As this test is much cheaper and moves or
> +     zero extensions are the common case, do this check first.  */
>    if (REG_P (operands[1])
> -      || (GET_CODE (operands[1]) == ZERO_EXTEND
> +      || (SImode_address_operand (operands[1], VOIDmode)
>           && REG_P (XEXP (operands[1], 0))))
>      return false;
>

Uros.
diff mbox

Patch

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c  (revision 206792)
+++ config/i386/i386.c  (working copy)
@@ -18160,13 +18160,12 @@  ix86_avoid_lea_for_addr (rtx insn, rtx operands[])
     return false;

   /* The "at least two components" test below might not catch simple
-     *mov[sd]i_internal or *zero_extendsidi2 insns if parts.base is
-     non-NULL and parts.disp is const0_rtx as the only components in
-     the address, e.g. if the register is %rbp or %r13.  As this
-     test is much cheaper and moves or zero extensions are the common
-     case, do this check first.  */
+     move or zero extension insns if parts.base is non-NULL and parts.disp
+     is const0_rtx as the only components in the address, e.g. if the
+     register is %rbp or %r13.  As this test is much cheaper and moves or
+     zero extensions are the common case, do this check first.  */
   if (REG_P (operands[1])
-      || (GET_CODE (operands[1]) == ZERO_EXTEND
+      || (SImode_address_operand (operands[1], VOIDmode)
          && REG_P (XEXP (operands[1], 0))))
     return false;