aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2016-04-09 13:23:51 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2016-04-09 13:23:51 +0200
commitf55460af163cc791a59bed42aa8f152417150a7e (patch)
tree278ad08deaf680f882d21d74af54385c37e7b401
parent0b77bbf392d30d1b9335c329131c4d7ce476a15f (diff)
downloadgcc-f55460af163cc791a59bed42aa8f152417150a7e.zip
gcc-f55460af163cc791a59bed42aa8f152417150a7e.tar.gz
gcc-f55460af163cc791a59bed42aa8f152417150a7e.tar.bz2
re PR tree-optimization/70586 (wrong code at -O2 and -O3 on x86_64-linux-gnu in 32-bit and 64-bit modes)
PR tree-optimization/70586 * tree-ssa-ifcombine.c (bb_no_side_effects_p): Return false for any calls. * gcc.c-torture/execute/pr70586.c: New test. From-SVN: r234849
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr70586.c30
-rw-r--r--gcc/tree-ssa-ifcombine.c9
4 files changed, 49 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index da9cfd8..7f2180d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2016-04-09 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/70586
+ * tree-ssa-ifcombine.c (bb_no_side_effects_p): Return false
+ for any calls.
+
2016-04-08 Cesar Philippidis <cesar@codesourcery.com>
PR lto/70289
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 48eb452..51fcbc9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-04-09 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/70586
+ * gcc.c-torture/execute/pr70586.c: New test.
+
2016-04-09 Dominique d'Humieres <dominiq@lps.ens.fr>
PR sanitizer/70573
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr70586.c b/gcc/testsuite/gcc.c-torture/execute/pr70586.c
new file mode 100644
index 0000000..32e9e50
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr70586.c
@@ -0,0 +1,30 @@
+/* PR tree-optimization/70586 */
+
+int a, e, f;
+short b, c, d;
+
+int
+foo (int x, int y)
+{
+ return (y == 0 || (x && y == 1)) ? x : x % y;
+}
+
+static short
+bar (void)
+{
+ int i = foo (c, f);
+ f = foo (d, 2);
+ int g = foo (b, c);
+ int h = foo (g > 0, c);
+ c = (3 >= h ^ 7) <= foo (i, c);
+ if (foo (e, 1))
+ return a;
+ return 0;
+}
+
+int
+main ()
+{
+ bar ();
+ return 0;
+}
diff --git a/gcc/tree-ssa-ifcombine.c b/gcc/tree-ssa-ifcombine.c
index 22b8b78..79fe3a8 100644
--- a/gcc/tree-ssa-ifcombine.c
+++ b/gcc/tree-ssa-ifcombine.c
@@ -125,7 +125,14 @@ bb_no_side_effects_p (basic_block bb)
if (gimple_has_side_effects (stmt)
|| gimple_uses_undefined_value_p (stmt)
|| gimple_could_trap_p (stmt)
- || gimple_vuse (stmt))
+ || gimple_vuse (stmt)
+ /* const calls don't match any of the above, yet they could
+ still have some side-effects - they could contain
+ gimple_could_trap_p statements, like floating point
+ exceptions or integer division by zero. See PR70586.
+ FIXME: perhaps gimple_has_side_effects or gimple_could_trap_p
+ should handle this. */
+ || is_gimple_call (stmt))
return false;
}