aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2006-05-25 12:39:52 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2006-05-25 12:39:52 +0000
commit2d60e929a169691cc5b5ac520364a9002af0c7cd (patch)
tree668a674da46ef3465f8087dae52ea497879ab501 /gcc
parent466a0c362fe022607a2cd05803988f952116d581 (diff)
downloadgcc-2d60e929a169691cc5b5ac520364a9002af0c7cd.zip
gcc-2d60e929a169691cc5b5ac520364a9002af0c7cd.tar.gz
gcc-2d60e929a169691cc5b5ac520364a9002af0c7cd.tar.bz2
re PR middle-end/27743 (Wrong code for ((unsigned) ((a) >> 2)) >> 15)
2006-05-25 Richard Guenther <rguenther@suse.de> PR middle-end/27743 * fold-const.c (fold_binary): Do not look at the stripped op0 for (a OP c1) OP c2 to a OP (c1+c2) shift optimization. * gcc.dg/torture/pr27743.c: New testcase. From-SVN: r114112
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/fold-const.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr27743.c15
4 files changed, 27 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 64117ca..368b3de 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2006-05-25 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/27743
+ * fold-const.c (fold_binary): Do not look at the stripped
+ op0 for (a OP c1) OP c2 to a OP (c1+c2) shift optimization.
+
2006-05-25 Eric Botcazou <ebotcazou@adacore.com>
* tree-vrp.c (extract_range_from_assert): Set the range to VARYING
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 8672e48..a5e57b1 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -9786,7 +9786,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
return NULL_TREE;
/* Turn (a OP c1) OP c2 into a OP (c1+c2). */
- if (TREE_CODE (arg0) == code && host_integerp (arg1, false)
+ if (TREE_CODE (op0) == code && host_integerp (arg1, false)
&& TREE_INT_CST_LOW (arg1) < TYPE_PRECISION (type)
&& host_integerp (TREE_OPERAND (arg0, 1), false)
&& TREE_INT_CST_LOW (TREE_OPERAND (arg0, 1)) < TYPE_PRECISION (type))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 02de3f5..4e3a9b8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2006-05-25 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/27743
+ * gcc.dg/torture/pr27743.c: New testcase.
+
2006-05-25 Eric Botcazou <ebotcazou@libertysurf.fr>
* gfortran.dg/large_real_kind_form_io_2.f90: UnXFAIL on SPARC/Solaris.
diff --git a/gcc/testsuite/gcc.dg/torture/pr27743.c b/gcc/testsuite/gcc.dg/torture/pr27743.c
new file mode 100644
index 0000000..ee9144a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr27743.c
@@ -0,0 +1,15 @@
+/* { dg-do run } */
+
+extern void abort(void);
+
+int bar(int a)
+{
+ return ((unsigned) ((a) >> 2)) >> 15;
+}
+
+int main()
+{
+ if (bar (0xffff3000) != 0x1ffff)
+ abort ();
+ return 0;
+}