This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH]: Fix PR rtl-optimization/27971
On Dec 6, 2007 4:32 AM, Richard Guenther <richard.guenther@gmail.com> wrote:
>
> On Dec 6, 2007 1:12 PM, Andrew Pinski <pinskia@gmail.com> wrote:
> > On 12/6/07, Richard Guenther <richard.guenther@gmail.com> wrote:
> > > I stand corrected that we are not in regression-only fixes mode yet, so
> > > the patch is ok with a testcase.
> >
> >
> > Except I think this is not even a bug fix really, just an enchancement
> > so I don't think this should go for 4.3.
>
> Well, missed optimizations are also bugs of some sort... at least that is
> what mattered in the past. Not that I agree with that too much.
>
> Richard.
Added a new testcase (this test passes with the proposed patch to
combine.c, and fails without it).
Ok for mainline?
Thanks,
raksit
2007-12-06 Raksit Ashok <raksit@google.com>
PR rtl-optimization/27971
* combine.c (find_split_point): introduced a new split for certain
types of mem rtx.
gcc/testsuite/ChangeLog
2007-12-06 Raksit Ashok <raksit@google.com>
PR rtl-optimization/27971
* gcc.target/i386/pr27971.c: New testcase.
Index: gcc/testsuite/gcc.target/i386/pr27971.c
===================================================================
--- gcc/testsuite/gcc.target/i386/pr27971.c (revision 0)
+++ gcc/testsuite/gcc.target/i386/pr27971.c (revision 0)
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+unsigned array[4];
+
+unsigned foo(unsigned long x)
+{
+ return array[(x>>2)&3ul];
+}
+
+/* { dg-final { scan-assembler-not "shr\[^\\n\]*2" } } */
+/* { dg-final { scan-assembler "and\[^\\n\]*12" } } */
Index: gcc/combine.c
===================================================================
--- gcc/combine.c (revision 130592)
+++ gcc/combine.c (working copy)
@@ -3967,6 +3967,15 @@ find_split_point (rtx *loc, rtx insn)
&& OBJECT_P (SUBREG_REG (XEXP (XEXP (x, 0), 0)))))
return &XEXP (XEXP (x, 0), 0);
}
+
+ /* If we have a PLUS whose first operand is complex, try computing it
+ separately by making a split there. */
+ if (GET_CODE (XEXP (x, 0)) == PLUS
+ && ! memory_address_p (GET_MODE (x), XEXP (x, 0))
+ && ! OBJECT_P (XEXP (XEXP (x, 0), 0))
+ && ! (GET_CODE (XEXP (XEXP (x, 0), 0)) == SUBREG
+ && OBJECT_P (SUBREG_REG (XEXP (XEXP (x, 0), 0)))))
+ return &XEXP (XEXP (x, 0), 0);
break;
case SET: