summaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-05-08 09:32:20 +0200
committerJakub Jelinek <jakub@redhat.com>2020-05-08 09:32:20 +0200
commitff33680165346cb291667f38dd2e9f25a74cc3c3 (patch)
tree357d4e2d6b76e6805659de387b7d161523eaceae /gcc/testsuite
parentaf1634f1b555004753a22d1124dbb8419ee095cb (diff)
match.pd: Simplify unsigned A - B - 1 >= A to B >= A [PR94913]
Implemented thusly. The TYPE_OVERFLOW_WRAPS is there just because the pattern above it has it too, if you want, I can throw it away from both. 2020-05-08 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/94913 * match.pd (A - B + -1 >= A to B >= A): New simplification. (A - B > A to A < B): Don't test TYPE_OVERFLOW_WRAPS which is always true for TYPE_UNSIGNED integral types. * gcc.dg/tree-ssa/pr94913.c: New test.
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr94913.c33
2 files changed, 38 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 088b80ea38f..43e226e7e18 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-05-08 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/94913
+ * gcc.dg/tree-ssa/pr94913.c: New test.
+
2020-05-07 Segher Boessenkool <segher@kernel.crashing.org>
* gcc.target/powerpc/setnbc.h: New.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr94913.c b/gcc/testsuite/gcc.dg/tree-ssa/pr94913.c
new file mode 100644
index 00000000000..6b71f98b013
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr94913.c
@@ -0,0 +1,33 @@
+/* PR tree-optimization/94913 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-final { scan-tree-dump " (?:b_\[0-9]+\\\(D\\\) >= a|a_\[0-9]+\\\(D\\\) <= b)_\[0-9]+\\\(D\\\);" "optimized" } } */
+/* { dg-final { scan-tree-dump " (?:c_\[0-9]+\\\(D\\\) > d|d_\[0-9]+\\\(D\\\) < c)_\[0-9]+\\\(D\\\);" "optimized" } } */
+/* { dg-final { scan-tree-dump " (?:f_\[0-9]+\\\(D\\\) >= e|e_\[0-9]+\\\(D\\\) <= f)_\[0-9]+\\\(D\\\);" "optimized" } } */
+/* { dg-final { scan-tree-dump " (?:g_\[0-9]+\\\(D\\\) > h|h_\[0-9]+\\\(D\\\) < g)_\[0-9]+\\\(D\\\);" "optimized" } } */
+
+int
+foo (unsigned a, unsigned b)
+{
+ return (a - b - 1) >= a;
+}
+
+int
+bar (unsigned c, unsigned d)
+{
+ return (c - d - 1) < c;
+}
+
+int
+baz (unsigned e, unsigned f)
+{
+ unsigned t = e - f;
+ return (t - 1) >= e;
+}
+
+int
+qux (unsigned g, unsigned h)
+{
+ unsigned t = g - h;
+ return (t - 1) < g;
+}