--- /dev/null
+/* { dg-do compile } */
+
+
+/* PR tree-optimization/117496 */
+/* This would go into an infinite loop into VN while recording
+ the predicates for the `tracks == 0 && wm == 0` GIMPLE_COND.
+ As wm_N and tracks_N would valueize back to `tracks | wm`. */
+
+int main_argc, gargs_preemp, gargs_nopreemp;
+static void gargs();
+void main_argv() {
+ int tracks = 0;
+ gargs(main_argc, main_argv, &tracks);
+}
+void gargs(int, char *, int *tracksp) {
+ int tracks = *tracksp, wm;
+ for (;;) {
+ if (tracks == 0)
+ wm |= 4;
+ if (gargs_nopreemp)
+ gargs_preemp = 0;
+ if (tracks == 0 && wm == 0)
+ tracks++;
+ }
+}
/* Insert on the TRUE_E true and FALSE_E false predicates
derived from LHS CODE RHS. */
+
static void
insert_predicates_for_cond (tree_code code, tree lhs, tree rhs,
edge true_e, edge false_e)
tree nlhs;
nlhs = vn_valueize (gimple_assign_rhs1 (def_stmt));
- insert_predicates_for_cond (EQ_EXPR, nlhs, rhs, e, nullptr);
+ /* A valueization of the `a` might return the old lhs
+ which is already handled above. */
+ if (nlhs != lhs)
+ insert_predicates_for_cond (EQ_EXPR, nlhs, rhs, e, nullptr);
+ /* A valueization of the `b` might return the old lhs
+ which is already handled above. */
nlhs = vn_valueize (gimple_assign_rhs2 (def_stmt));
- insert_predicates_for_cond (EQ_EXPR, nlhs, rhs, e, nullptr);
+ if (nlhs != lhs)
+ insert_predicates_for_cond (EQ_EXPR, nlhs, rhs, e, nullptr);
}
}
}