From f7626d1ebf828f85179102240ce705a023bbd566 Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Wed, 11 Mar 2020 09:04:11 +0100 Subject: Remove special checks for equivalences of the form: X .relop. Y. It turns out these "equivalences" really only register overflow checks. They notice: unsigned_sum = unsigned_a + 1 if (unsigned_sum > unsigned_a) and register that unsigned_a < MAXINT. Instead of special checking this in the comparison and trap code, set gori_computable=false in the overflow checking code. --- gcc/gimple-ssa-evrp-analyze.c | 6 ------ gcc/tree-vrp.c | 9 +++++++++ 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'gcc') diff --git a/gcc/gimple-ssa-evrp-analyze.c b/gcc/gimple-ssa-evrp-analyze.c index d214418..0f14713 100644 --- a/gcc/gimple-ssa-evrp-analyze.c +++ b/gcc/gimple-ssa-evrp-analyze.c @@ -204,14 +204,8 @@ vr_gori_comparison::compare (tree name, edge e, vr_values *vr) { gcond *gc = as_a (stmt); tree lhs = gimple_cond_lhs (gc); - tree rhs = gimple_cond_rhs (gc); if (TREE_CODE (lhs) == SSA_NAME) { - // Comparison between two SSA_NAMEs are equivalences which the - // ranger will handle. - if (TREE_CODE (rhs) == SSA_NAME) - return; - // Ignore problematic casts for which evrp lies and ignores // the upper bits. // diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 2a9e434..1270d19 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -1863,6 +1863,15 @@ register_edge_assert_for_2 (tree name, edge e, { enum tree_code new_code = ((comp_code == GT_EXPR || comp_code == GE_EXPR) ? GT_EXPR : LE_EXPR); + + // When noticing an overflow check: + // + // unsigned_sum = unsigned_a + 1 + // if (unsigned_sum > unsigned_a) + // + // ...evrp registers that unsigned_a < MAXINT. + // This is technically an equivalence, so keep gori from checking this. + gori_computable set_gori_computable (false); add_assert_info (asserts, name, name, new_code, x); } add_assert_info (asserts, name, name, comp_code, val); -- cgit v1.1