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

login
register
mail settings
Submitter Uros Bizjak
Date March 13, 2012, 4:21 p.m.
Message ID <CAFULd4bT9_KaDJRuaBEG_vdMSB8_qWAtWQxbu5737KejU0X6Pw@mail.gmail.com>
Download mbox | patch
Permalink /patch/146441/
State New
Headers show

Comments

Uros Bizjak - March 13, 2012, 4:21 p.m.
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.

Uros.
H.J. Lu - March 13, 2012, 8:01 p.m.
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]

with -mx32 on Linux/x86-64.
Uros Bizjak - March 13, 2012, 8:09 p.m.
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]))

Will fix tomorrow.

Thanks,
Uros.

Patch

Index: i386.c
===================================================================
--- i386.c	(revision 185327)
+++ i386.c	(working copy)
@@ -11435,10 +11435,14 @@  ix86_decompose_address (rtx addr, struct ix86_addr
 	{
 	  addr = XEXP (addr, 0);
 
-	  /* Strip subreg.  */
-	  if (GET_CODE (addr) == SUBREG
-	      && GET_MODE (SUBREG_REG (addr)) == SImode)
+	  /* Adjust SUBREGs.  */
+	  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;
 	}
     }