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.
--- /dev/null
+/* { 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);
+}
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)