[gcc r10-8747] tree-optimization/96514 - avoid if-converting control-altering calls
Richard Biener
rguenth@gcc.gnu.org
Fri Sep 11 12:12:05 GMT 2020
https://gcc.gnu.org/g:a568a893f38a9cd32ddffd32bb9b6636deeeb5f1
commit r10-8747-ga568a893f38a9cd32ddffd32bb9b6636deeeb5f1
Author: Richard Biener <rguenther@suse.de>
Date: Fri Aug 7 10:16:05 2020 +0200
tree-optimization/96514 - avoid if-converting control-altering calls
This avoids if-converting when encountering control-altering calls.
2020-08-07 Richard Biener <rguenther@suse.de>
PR tree-optimization/96514
* tree-if-conv.c (if_convertible_bb_p): If the last stmt
is a call that is control-altering, fail.
* gcc.dg/pr96514.c: New testcase.
(cherry picked from commit c3f94f5786a014515c09c7852db228c74adf51e5)
Diff:
---
gcc/testsuite/gcc.dg/pr96514.c | 27 +++++++++++++++++++++++++++
gcc/tree-if-conv.c | 5 +++++
2 files changed, 32 insertions(+)
diff --git a/gcc/testsuite/gcc.dg/pr96514.c b/gcc/testsuite/gcc.dg/pr96514.c
new file mode 100644
index 00000000000..891b4da2b1e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr96514.c
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+
+int __attribute__ ((pure, returns_twice))
+r0 (void);
+
+void
+vy (int t7)
+{
+ while (t7 == 0)
+ r0 ();
+}
+
+void
+qw (int t7)
+{
+ vy (t7);
+
+ if (0)
+ r0 ();
+}
+
+void __attribute__ ((simd))
+un (int t7)
+{
+ qw (t7);
+ qw (t7);
+}
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index fc894eb94da..257759d01bf 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -1139,6 +1139,11 @@ if_convertible_bb_p (class loop *loop, basic_block bb, basic_block exit_bb)
if (EDGE_COUNT (bb->succs) > 2)
return false;
+ gimple *last = last_stmt (bb);
+ if (gcall *call = safe_dyn_cast <gcall *> (last))
+ if (gimple_call_ctrl_altering_p (call))
+ return false;
+
if (exit_bb)
{
if (bb != loop->latch)
More information about the Gcc-cvs
mailing list