diff options
author | Jeff Law <law@redhat.com> | 2017-12-19 13:13:04 -0700 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2017-12-19 13:13:04 -0700 |
commit | 72de3b780004c74097d7b26c5f169de46f546998 (patch) | |
tree | db897bbf37a558de4fd1fe439a95d46f628736f9 /gcc/tree-ssa-threadedge.c | |
parent | af3fa359b4b7335008652b9f1eefbd41ac8216d9 (diff) | |
download | gcc-72de3b780004c74097d7b26c5f169de46f546998.zip gcc-72de3b780004c74097d7b26c5f169de46f546998.tar.gz gcc-72de3b780004c74097d7b26c5f169de46f546998.tar.bz2 |
re PR middle-end/83477 (Wrong code w/ -O1)
PR tree-optimization/83477
* tree-ssa-threadedge.c (record_temporary_equivalences_from_phis): For
a non-virtual PHI, always push a new range.
PR tree-optimization/83477
* gcc.c-torture/execute/pr83477.c: New test.
From-SVN: r255837
Diffstat (limited to 'gcc/tree-ssa-threadedge.c')
-rw-r--r-- | gcc/tree-ssa-threadedge.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c index 1fafd7b..0c782f5 100644 --- a/gcc/tree-ssa-threadedge.c +++ b/gcc/tree-ssa-threadedge.c @@ -156,11 +156,37 @@ record_temporary_equivalences_from_phis (edge e, const_and_copies->record_const_or_copy (dst, src); /* Also update the value range associated with DST, using - the range from SRC. */ - if (evrp_range_analyzer && TREE_CODE (src) == SSA_NAME) + the range from SRC. + + Note that even if SRC is a constant we need to set a suitable + output range so that VR_UNDEFINED ranges do not leak through. */ + if (evrp_range_analyzer) { - value_range *vr = evrp_range_analyzer->get_value_range (src); - evrp_range_analyzer->push_value_range (dst, vr); + /* Get an empty new VR we can pass to update_value_range and save + away in the VR stack. */ + vr_values *vr_values = evrp_range_analyzer->get_vr_values (); + value_range *new_vr = vr_values->allocate_value_range (); + memset (new_vr, 0, sizeof (value_range)); + + /* There are three cases to consider: + + First if SRC is an SSA_NAME, then we can copy the value + range from SRC into NEW_VR. + + Second if SRC is an INTEGER_CST, then we can just wet + NEW_VR to a singleton range. + + Otherwise set NEW_VR to varying. This may be overly + conservative. */ + if (TREE_CODE (src) == SSA_NAME) + copy_value_range (new_vr, vr_values->get_value_range (src)); + else if (TREE_CODE (src) == INTEGER_CST) + set_value_range_to_value (new_vr, src, NULL); + else + set_value_range_to_varying (new_vr); + + /* This is a temporary range for DST, so push it. */ + evrp_range_analyzer->push_value_range (dst, new_vr); } } return true; |