Commit 0ad12cd3 by Serge Belyshev Committed by Roger Sayle

re PR middle-end/29726 (invalid folding of ((X >> C1) & C2) != 0 or "M-x is undefined" in emacs)

2006-11-09  Serge Belyshev  <belyshev@depni.sinp.msu.ru>

	PR middle-end/29726
	* fold-const.c (fold_binary) <EQ_EXPR>: Fix typo in variable name.

	* 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.

From-SVN: r118625
parent 7114edca
2006-11-09 Serge Belyshev <belyshev@depni.sinp.msu.ru>
PR middle-end/29726
* fold-const.c (fold_binary) <EQ_EXPR>: Fix typo in variable name.
2006-11-09 Andreas Krebbel <krebbel1@de.ibm.com> 2006-11-09 Andreas Krebbel <krebbel1@de.ibm.com>
* simplify-rtx.c (avoid_constant_pool_reference): Avoid calling * simplify-rtx.c (avoid_constant_pool_reference): Avoid calling
......
...@@ -10587,7 +10587,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) ...@@ -10587,7 +10587,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
unsigned HOST_WIDE_INT log2 = tree_log2 (arg01); unsigned HOST_WIDE_INT log2 = tree_log2 (arg01);
/* If (C2 << C1) doesn't overflow, then ((X >> C1) & C2) != 0 /* If (C2 << C1) doesn't overflow, then ((X >> C1) & C2) != 0
can be rewritten as (X & (C2 << C1)) != 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 (LSHIFT_EXPR, itype, arg01, arg001);
tem = fold_build2 (BIT_AND_EXPR, itype, arg000, tem); tem = fold_build2 (BIT_AND_EXPR, itype, arg000, tem);
......
2006-11-09 Serge Belyshev <belyshev@depni.sinp.msu.ru>
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.
2006-11-09 Paul Thomas <pault@gcc.gnu.org> 2006-11-09 Paul Thomas <pault@gcc.gnu.org>
PR fortran/29699 PR fortran/29699
...@@ -25,7 +25,6 @@ int test4(int d) ...@@ -25,7 +25,6 @@ int test4(int d)
return (d >> 3) & 4; return (d >> 3) & 4;
} }
#if 0
void test5(int e) void test5(int e)
{ {
if ((e >> 31) & 64) if ((e >> 31) & 64)
...@@ -37,10 +36,11 @@ void test6(unsigned int f) ...@@ -37,10 +36,11 @@ void test6(unsigned int f)
if ((f >> 31) & 64) if ((f >> 31) & 64)
foo(); foo();
} }
#endif
/* { dg-final { scan-tree-dump-times "\\(a \& 8\\) != 0" 1 "original" } } */ /* { 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 "\\(b \& 32\\) != 0" 1 "original" } } */
/* { dg-final { scan-tree-dump-times "c >> 3 \& 1" 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 "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" } } */ /* { dg-final { cleanup-tree-dump "original" } } */
/* 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" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment