aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2020-03-11 09:04:11 +0100
committerAldy Hernandez <aldyh@redhat.com>2020-03-11 10:40:09 +0100
commitf7626d1ebf828f85179102240ce705a023bbd566 (patch)
tree457c695ea0271b83eb12246bebcc2cdda7d38f07 /gcc
parent1ece551411eb8533da304ed20d380febc75dc694 (diff)
downloadgcc-f7626d1ebf828f85179102240ce705a023bbd566.zip
gcc-f7626d1ebf828f85179102240ce705a023bbd566.tar.gz
gcc-f7626d1ebf828f85179102240ce705a023bbd566.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/gimple-ssa-evrp-analyze.c6
-rw-r--r--gcc/tree-vrp.c9
2 files changed, 9 insertions, 6 deletions
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<gcond *> (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);