aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2021-01-05 19:13:29 +0100
committerJakub Jelinek <jakub@redhat.com>2021-01-05 19:13:29 +0100
commit5de7bf5bc98ec9edc6838a443521204d0eca7605 (patch)
tree388829cc39978cb2685f30f05b83652575aec353 /gcc/testsuite
parent6b577a17b26347e78c8b9167f24fc5c9d9724270 (diff)
downloadgcc-5de7bf5bc98ec9edc6838a443521204d0eca7605.zip
gcc-5de7bf5bc98ec9edc6838a443521204d0eca7605.tar.gz
gcc-5de7bf5bc98ec9edc6838a443521204d0eca7605.tar.bz2
expand: Fold x - y < 0 to x < y during expansion [PR94802]
My earlier patch to simplify x - y < 0 etc. for signed subtraction with undefined overflow into x < y in match.pd regressed some tests, even when it was guarded to be post-IPA, the following patch thus attempts to optimize that during expansion instead (which is the last time we can do it, afterwards we lose the information whether it was x - y < 0 or (int) ((unsigned) x - y) < 0 for which we couldn't optimize it. 2021-01-05 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/94802 * expr.h (maybe_optimize_sub_cmp_0): Declare. * expr.c: Include tree-pretty-print.h and flags.h. (maybe_optimize_sub_cmp_0): New function. (do_store_flag): Use it. * cfgexpand.c (expand_gimple_cond): Likewise. * gcc.target/i386/pr94802.c: New test. * gcc.dg/Wstrict-overflow-25.c: Remove xfail.
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/gcc.dg/Wstrict-overflow-25.c2
-rw-r--r--gcc/testsuite/gcc.target/i386/pr94802.c59
2 files changed, 60 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.dg/Wstrict-overflow-25.c b/gcc/testsuite/gcc.dg/Wstrict-overflow-25.c
index 774474d..0091644 100644
--- a/gcc/testsuite/gcc.dg/Wstrict-overflow-25.c
+++ b/gcc/testsuite/gcc.dg/Wstrict-overflow-25.c
@@ -7,5 +7,5 @@
int
foo (int x, int y)
{
- return x - y < 0; /* { dg-warning "assuming signed overflow does not occur" "correct warning" { xfail *-*-* } } */
+ return x - y < 0; /* { dg-warning "assuming signed overflow does not occur" "correct warning" } */
}
diff --git a/gcc/testsuite/gcc.target/i386/pr94802.c b/gcc/testsuite/gcc.target/i386/pr94802.c
new file mode 100644
index 0000000..6c1bc66
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr94802.c
@@ -0,0 +1,59 @@
+/* PR tree-optimization/94802 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -masm=att" } */
+/* { dg-final { scan-assembler-not "\ttestl\t" } } */
+/* { dg-final { scan-assembler-times "\tcmpl\t" 8 } } */
+
+void foo (void);
+
+int
+f1 (int a, int b)
+{
+ return (a - b) >= 0;
+}
+
+int
+f2 (int a, int b)
+{
+ return (a - b) > 0;
+}
+
+int
+f3 (int a, int b)
+{
+ return (a - b) <= 0;
+}
+
+int
+f4 (int a, int b)
+{
+ return (a - b) < 0;
+}
+
+void
+f5 (int a, int b)
+{
+ if ((a - b) >= 0)
+ foo ();
+}
+
+void
+f6 (int a, int b)
+{
+ if ((a - b) > 0)
+ foo ();
+}
+
+void
+f7 (int a, int b)
+{
+ if ((a - b) <= 0)
+ foo ();
+}
+
+void
+f8 (int a, int b)
+{
+ if ((a - b) < 0)
+ foo ();
+}