aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2020-03-11 17:29:50 +0100
committerAldy Hernandez <aldyh@redhat.com>2020-03-11 17:29:55 +0100
commit2b00c489070afb0d4891d5ba41d8847aa2cb3db1 (patch)
tree01923310d3f50b91a9c7b350a6206a857d6a0201
parent4f40aee87d1598407aafd9bb35a491d46c766c19 (diff)
downloadgcc-2b00c489070afb0d4891d5ba41d8847aa2cb3db1.zip
gcc-2b00c489070afb0d4891d5ba41d8847aa2cb3db1.tar.gz
gcc-2b00c489070afb0d4891d5ba41d8847aa2cb3db1.tar.bz2
Disable generic ignoring of narrowing casts in favor of finer grained.
-rw-r--r--gcc/gimple-ssa-evrp-analyze.c23
-rw-r--r--gcc/tree-vrp.c9
2 files changed, 9 insertions, 23 deletions
diff --git a/gcc/gimple-ssa-evrp-analyze.c b/gcc/gimple-ssa-evrp-analyze.c
index 0f14713..cbcee21 100644
--- a/gcc/gimple-ssa-evrp-analyze.c
+++ b/gcc/gimple-ssa-evrp-analyze.c
@@ -197,29 +197,6 @@ vr_gori_comparison::compare (tree name, edge e, vr_values *vr)
dump_improvements (dump_file);
return;
}
- // Ignore known discrepancies.
- widest_irange tmp;
- gimple *stmt = gimple_outgoing_edge_range_p (tmp, m_edge);
- if (stmt && is_a<gcond *> (stmt))
- {
- gcond *gc = as_a<gcond *> (stmt);
- tree lhs = gimple_cond_lhs (gc);
- if (TREE_CODE (lhs) == SSA_NAME)
- {
- // Ignore problematic casts for which evrp lies and ignores
- // the upper bits.
- //
- // SMALLER = (cast) NAME
- // if (SMALLER == 0)
- gimple *def = SSA_NAME_DEF_STMT (lhs);
- if (def
- && gimple_assign_cast_p (def)
- && gimple_assign_rhs1 (def) == name
- && (TYPE_PRECISION (TREE_TYPE (name))
- > TYPE_PRECISION (TREE_TYPE (lhs))))
- return;
- }
- }
dump_differences_and_trap ();
}
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index a9d85ed..ead8552 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -2188,6 +2188,7 @@ register_edge_assert_for_2 (tree name, edge e,
names[0] = NULL_TREE;
names[1] = NULL_TREE;
cst2 = NULL_TREE;
+ bool problematic_cast = false;
if (rhs_code == BIT_AND_EXPR
|| (CONVERT_EXPR_CODE_P (rhs_code)
&& INTEGRAL_TYPE_P (TREE_TYPE (val))
@@ -2195,6 +2196,13 @@ register_edge_assert_for_2 (tree name, edge e,
&& TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs1 (def_stmt)))
> prec))
{
+ // This catches problematic truncating casts.
+ //
+ // Trigger is c-c++-common/torture/builtin-arith-overflow-p-19.c
+ // and gimple.c.
+ if (CONVERT_EXPR_CODE_P (rhs_code))
+ problematic_cast = true;
+
name2 = gimple_assign_rhs1 (def_stmt);
if (rhs_code == BIT_AND_EXPR)
cst2 = gimple_assign_rhs2 (def_stmt);
@@ -2381,6 +2389,7 @@ register_edge_assert_for_2 (tree name, edge e,
if (valid_p
&& (maxv - minv) != -1)
{
+ gori_computable set_gori_computable (!problematic_cast);
tree tmp, new_val, type;
int i;