diff mbox

[i386] : Handle subregs of AND zero extended address correctly

Message ID CAFULd4YZPb=mNgQ4fFu4UHedrxdiC-0cE=VVpJqFG-xhx_F6WA@mail.gmail.com
State New
Headers show

Commit Message

Uros Bizjak March 13, 2012, 8:15 p.m. UTC
On Tue, Mar 13, 2012 at 9:09 PM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Tue, Mar 13, 2012 at 9:01 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Tue, Mar 13, 2012 at 9:21 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
>>> Hello!
>>>
>>> We allow addresses, zero extended with (AND (Dimode OP)
>>> (0x0ffffffff)). Since we now track address mode precisely, we should
>>> convert this operand to a SImode subreg before passing it further down
>>> of ix86_decompose_address function. This fixes a small hole, where
>>> operands in wrong mode could squeeze through.
>>>
>>> 2012-03-13  Uros Bizjak  <ubizjak@gmail.com>
>>>
>>>        * config/i386/i386.c (ix86_decompose_address): Handle subregs of
>>>        AND zero extended address correctly.
>>>
>>> Tested on x86_64-pc-linux-gnu {,-m32}, committed to mainline SVN.
>>
>> I think this caused:
>>
>> FAIL: gcc.target/i386/pr43766.c scan-assembler-not lea[lq]?[ \t]
>
> Ah, we also need to consider:
>
> Failed to match this instruction:
> (prefetch (and:DI (subreg:DI (plus:SI (ashift:SI (reg/v:SI 63 [ i ])
>                    (const_int 2 [0x2]))
>                (subreg:SI (reg/v/f:DI 62 [ a ]) 0)) 0)
>        (const_int 4294967295 [0xffffffff]))
>    (const_int 0 [0])
>    (const_int 3 [0x3]))

Fixed by attached patch.

Committed.

Uros.
diff mbox

Patch

Index: i386.c
===================================================================
--- i386.c      (revision 185351)
+++ i386.c      (working copy)
@@ -11436,11 +11436,11 @@ 
          addr = XEXP (addr, 0);

          /* Adjust SUBREGs.  */
-         if (GET_MODE (addr) == DImode)
+         if (GET_CODE (addr) == SUBREG
+             && GET_MODE (SUBREG_REG (addr)) == SImode)
+           addr = SUBREG_REG (addr);
+         else if (GET_MODE (addr) == DImode)
            addr = gen_rtx_SUBREG (SImode, addr, 0);
-         else if (GET_CODE (addr) == SUBREG
-                  && GET_MODE (SUBREG_REG (addr)) == SImode)
-           addr = SUBREG_REG (addr);
          else
            return 0;
        }