Patchwork [i386] : Fix PR 53961 in a different way

login
register
mail settings
Submitter Uros Bizjak
Date July 23, 2012, 6:48 a.m.
Message ID <CAFULd4a+8z2D=H_FQc4vqG03NSYbVGGr-xpnko9WYD-h64QHMw@mail.gmail.com>
Download mbox | patch
Permalink /patch/172550/
State New
Headers show

Comments

Uros Bizjak - July 23, 2012, 6:48 a.m.
On Sun, Jul 22, 2012 at 5:39 PM, Uros Bizjak <ubizjak@gmail.com> wrote:

> The core of the problem was in fact the possibility of invalid
> addresses to sneak through various LEA patterns.
>
> Attached patch adds handling of SImode SUBREGs of addresses to generic
> code. This way, we can use one LEA pattern that accepts all valid
> address RTXes (modulo segment prefixed ones).
>
> 2012-07-22  Uros Bizjak  <ubizjak@gmail.com>
>
>         PR target/53961
>         * config/i386/i386.md (*lea): New insn pattern.
>         (*lea_1): Remove.
>         (*lea<mode>_2): Ditto.
>         (*lea_{3,4,5,6}_zext): Ditto.
>         * config/i386/constraints.md (j): Remove address constraint.
>         * config/i386/i386.c (ix86_decompose_address): Allow SImode subreg
>         of an address.
>         (ix86_print_operand_address): Handle SImode subreg of an address.
>         (ix86_avoid_lea_for_add): Reject zero-extended addresses for now.

Following patch fixes an overlook ... we have to prevent zero extended
addresses in ix86_avoid_lea_for_addr, not ix86_avoid_lea_for_add. Spot
the difference in function names. ;)

Uros.

Patch

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c  (revision 189767)
+++ config/i386/i386.c  (working copy)
@@ -16864,11 +16864,6 @@  ix86_avoid_lea_for_add (rtx insn, rtx operands[])
   unsigned int regno1 = true_regnum (operands[1]);
   unsigned int regno2 = true_regnum (operands[2]);

-  /* FIXME: Handle zero-extended addresses.  */
-  if (GET_CODE (operands[1]) == ZERO_EXTEND
-      || GET_CODE (operands[1]) == AND)
-    return false;
-
   /* Check if we need to optimize.  */
   if (!TARGET_OPT_AGU || optimize_function_for_size_p (cfun))
     return false;
@@ -16921,6 +16916,11 @@  ix86_avoid_lea_for_addr (rtx insn, rtx operands[])
   struct ix86_address parts;
   int ok;

+  /* FIXME: Handle zero-extended addresses.  */
+  if (GET_CODE (operands[1]) == ZERO_EXTEND
+      || GET_CODE (operands[1]) == AND)
+    return false;
+
   /* Check we need to optimize.  */
   if (!TARGET_OPT_AGU || optimize_function_for_size_p (cfun))
     return false;