http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59379

--- Comment #17 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Uroš Bizjak from comment #16)
> (In reply to H.J. Lu from comment #15)
> 
> > Either patch fixes the problem.
> 
> I prefer first patch. It splits all LEAs, where ix86_avoid_lea_for_addr is
> true.

Then we should avoid the extra

(set (reg:DI) (zero_extend:DI (reg:SI)))

by

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index ff210c8..346b0cb 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -18342,6 +18342,23 @@ ix86_split_lea_for_addr (rtx insn, rtx operands[],
enum machine_mode mode)
     }
   else
     {
+      if (mode != GET_MODE (operands[0]))
+    {
+      gcc_assert (mode == SImode && GET_MODE (operands[0]) == DImode);
+      if ((!parts.disp || parts.disp == const0_rtx)
+          && ((parts.base && !parts.index)
+          || (!parts.base && parts.index)))
+        {
+          if (parts.base)
+        emit_insn (gen_zero_extendsidi2 (operands[0],
+                         parts.base));
+          else
+        emit_insn (gen_zero_extendsidi2 (operands[0],
+                         parts.index));
+          return;
+        }
+    }
+
       if (!parts.base)
     {
       if (regno0 != regno2)

Reply via email to