aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2016-06-07 07:30:47 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2016-06-07 07:30:47 +0000
commit0f3f94375a989a45df3c315789f0fc62bbf39989 (patch)
tree4acd58ee5cf0f663525e480405a65346172abaf2
parentdf32c0b335a41c8ca522433d6df04c647cc6d495 (diff)
downloadgcc-0f3f94375a989a45df3c315789f0fc62bbf39989.zip
gcc-0f3f94375a989a45df3c315789f0fc62bbf39989.tar.gz
gcc-0f3f94375a989a45df3c315789f0fc62bbf39989.tar.bz2
re PR tree-optimization/71423 (wrong code at -Os and above on x86_64-linux-gnu)
2016-06-07 Richard Biener <rguenther@suse.de> PR middle-end/71423 * match.pd ((X | ~Y) -> Y <= X): Properly invert the comparison for signed ops. * gcc.dg/torture/pr71423.c: New testcase. From-SVN: r237166
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/match.pd8
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr71423.c20
4 files changed, 37 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index edc45f5..878ee3a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2016-06-07 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/71423
+ * match.pd ((X | ~Y) -> Y <= X): Properly invert the comparison
+ for signed ops.
+
2016-06-06 John David Anglin <danglin@gcc.gnu.org>
* config/pa/pa.md (call): Generate indirect long calls to non-local
diff --git a/gcc/match.pd b/gcc/match.pd
index 4d66243..fe71115 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -900,12 +900,16 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(ne (bit_and:c (bit_not @0) @1) integer_zerop)
(if (INTEGRAL_TYPE_P (TREE_TYPE (@1))
&& TYPE_PRECISION (TREE_TYPE (@1)) == 1)
- (lt @0 @1)))
+ (if (TYPE_UNSIGNED (TREE_TYPE (@1)))
+ (lt @0 @1)
+ (gt @0 @1))))
(simplify
(ne (bit_ior:c (bit_not @0) @1) integer_zerop)
(if (INTEGRAL_TYPE_P (TREE_TYPE (@1))
&& TYPE_PRECISION (TREE_TYPE (@1)) == 1)
- (le @0 @1)))
+ (if (TYPE_UNSIGNED (TREE_TYPE (@1)))
+ (le @0 @1)
+ (ge @0 @1))))
/* ~~x -> x */
(simplify
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a1a7f19..52bb629 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-06-07 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/71423
+ * gcc.dg/torture/pr71423.c: New testcase.
+
2016-06-07 Kugan Vivekanandarajah <kuganv@linaro.org>
PR middle-end/71408
diff --git a/gcc/testsuite/gcc.dg/torture/pr71423.c b/gcc/testsuite/gcc.dg/torture/pr71423.c
new file mode 100644
index 0000000..06a613f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr71423.c
@@ -0,0 +1,20 @@
+/* { dg-do run } */
+
+struct S1
+{
+ int f1:1;
+};
+
+volatile struct S1 b = { 0 };
+
+int
+main ()
+{
+ char c = b.f1;
+ b.f1 = 1;
+
+ if (b.f1 > -1 || c)
+ __builtin_abort ();
+
+ return 0;
+}