--- /dev/null
+/* { dg-do run } */
+/* The -Waggressive-loop-optimizations diagnostic is spurious, missed
+ constant propagation after final value replacement. */
+/* { dg-additional-options "-Wno-aggressive-loop-optimizations -fsplit-loops" } */
+
+volatile int a;
+int main()
+{
+ for (int b = 0; b < 33; b += 3) {
+ if (b > 31)
+ a++;
+ }
+ if (a != 0)
+ __builtin_abort();
+ return 0;
+}
also be true/false in the next iteration. */
static void
-patch_loop_exit (class loop *loop, gcond *guard, tree nextval, tree newbound,
- bool initial_true)
+patch_loop_exit (class loop *loop, tree_code guard_code, tree nextval,
+ tree newbound, bool initial_true)
{
edge exit = single_exit (loop);
gcond *stmt = as_a <gcond *> (*gsi_last_bb (exit->src));
- gimple_cond_set_condition (stmt, gimple_cond_code (guard),
- nextval, newbound);
+ gimple_cond_set_condition (stmt, guard_code, nextval, newbound);
update_stmt (stmt);
edge stay = EDGE_SUCC (exit->src, EDGE_SUCC (exit->src, 0) == exit);
gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop1),
stmts);
tree guard_next = PHI_ARG_DEF_FROM_EDGE (phi, loop_latch_edge (loop1));
- patch_loop_exit (loop1, guard_stmt, guard_next, newend, initial_true);
+ patch_loop_exit (loop1, guard_code, guard_next, newend, initial_true);
/* Finally patch out the two copies of the condition to be always
true/false (or opposite). */