This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATH] fix middle-end/29726
- From: Serge Belyshev <belyshev at depni dot sinp dot msu dot ru>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Roger Sayle <roger at eyesopen dot com>
- Date: Tue, 07 Nov 2006 21:24:31 +0300
- Subject: [PATH] fix middle-end/29726
The PR29726 regression was caused by typo in PR21137 fix. This patch
fixes that, adds new test case for the fix and also enables two tests
in old PR21137 test case which were #if 0'd out for some reason.
This patch is for gcc-4_2-branch and trunk,
tested on x86_64-unknown-linux-gnu with no new regressions,
ensured that all four new tests will fail iff appropriate patches are reverted.
gcc/ChangeLog:
PR middle-end/29726
* fold-const.c (fold_binary) <EQ_EXPR>: fix typo in variable name.
gcc/testsuite/ChangeLog:
PR middle-end/29726
* gcc.dg/fold-eqandshift-1.c (test5): Uncomment function.
(test6): Ditto.
(dg-final): add scan-tree-dump-times patterns for test5 and test6.
* gcc.dg/fold-eqandshift-3.c: New test case.
fold-const.c | 2 +-
testsuite/gcc.dg/fold-eqandshift-1.c | 4 ++--
testsuite/gcc.dg/fold-eqandshift-3.c | 21 +++++++++++++++++++++
3 files changed, 24 insertions(+), 3 deletions(-)
Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c (revision 118542)
+++ gcc/fold-const.c (working copy)
@@ -10408,7 +10408,7 @@ fold_binary (enum tree_code code, tree t
unsigned HOST_WIDE_INT log2 = tree_log2 (arg01);
/* If (C2 << C1) doesn't overflow, then ((X >> C1) & C2) != 0
can be rewritten as (X & (C2 << C1)) != 0. */
- if ((log2 + TREE_INT_CST_LOW (arg01)) < prec)
+ if ((log2 + TREE_INT_CST_LOW (arg001)) < prec)
{
tem = fold_build2 (LSHIFT_EXPR, itype, arg01, arg001);
tem = fold_build2 (BIT_AND_EXPR, itype, arg000, tem);
Index: gcc/testsuite/gcc.dg/fold-eqandshift-1.c
===================================================================
--- gcc/testsuite/gcc.dg/fold-eqandshift-1.c (revision 118542)
+++ gcc/testsuite/gcc.dg/fold-eqandshift-1.c (working copy)
@@ -25,7 +25,6 @@ int test4(int d)
return (d >> 3) & 4;
}
-#if 0
void test5(int e)
{
if ((e >> 31) & 64)
@@ -37,10 +36,11 @@ void test6(unsigned int f)
if ((f >> 31) & 64)
foo();
}
-#endif
/* { dg-final { scan-tree-dump-times "\\(a \& 8\\) != 0" 1 "original" } } */
/* { dg-final { scan-tree-dump-times "\\(b \& 32\\) != 0" 1 "original" } } */
/* { dg-final { scan-tree-dump-times "c >> 3 \& 1" 1 "original" } } */
/* { dg-final { scan-tree-dump-times "d >> 3 \& 4" 1 "original" } } */
+/* { dg-final { scan-tree-dump-times "e < 0" 1 "original" } } */
+/* { dg-final { scan-tree-dump-times "if \\(0\\)" 1 "original" } } */
/* { dg-final { cleanup-tree-dump "original" } } */
Index: gcc/testsuite/gcc.dg/fold-eqandshift-3.c
===================================================================
--- gcc/testsuite/gcc.dg/fold-eqandshift-3.c (revision 0)
+++ gcc/testsuite/gcc.dg/fold-eqandshift-3.c (revision 0)
@@ -0,0 +1,21 @@
+/* PR middle-end/29726 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-original" } */
+
+void foo (void);
+
+int test1 (int a)
+{
+ if ((a >> 3) & 134217728)
+ foo ();
+}
+
+int test2 (unsigned int b)
+{
+ if ((b >> 3) & 134217728)
+ foo ();
+}
+
+/* { dg-final { scan-tree-dump-times "\\(a \& 1073741824\\) != 0" 1 "original" } } */
+/* { dg-final { scan-tree-dump-times "\\(b \& 1073741824\\) != 0" 1 "original" } } */
+/* { dg-final { cleanup-tree-dump "original" } } */