aboutsummaryrefslogtreecommitdiff
path: root/gcc/value-range.cc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2021-01-06 09:26:55 +0100
committerRichard Biener <rguenther@suse.de>2021-01-06 09:33:37 +0100
commita05cc70a6c1ae0e5b22e16f4d8d13995a38ea1f9 (patch)
tree4bf3a143b16e38f1dcb6d6b8cc72ece392047926 /gcc/value-range.cc
parent57706dd7e001d8302b596521217827855324e748 (diff)
downloadgcc-a05cc70a6c1ae0e5b22e16f4d8d13995a38ea1f9.zip
gcc-a05cc70a6c1ae0e5b22e16f4d8d13995a38ea1f9.tar.gz
gcc-a05cc70a6c1ae0e5b22e16f4d8d13995a38ea1f9.tar.bz2
tree-optimization/98513 - fix bug in range intersection code
This fixes a premature optimization in the range intersection code which assumes earlier branches have to be taken, not taking into account that for symbolic ranges we cannot always compare endpoints. The fix is to instantiate the compare deemed redundant (which then fails as undecidable for the testcase). 2021-01-06 Richard Biener <rguenther@suse.de> PR tree-optimization/98513 * value-range.cc (intersect_ranges): Compare the upper bounds for the expected relation. * gcc.dg/tree-ssa/pr98513.c: New testcase.
Diffstat (limited to 'gcc/value-range.cc')
-rw-r--r--gcc/value-range.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index c404787..9c42f82 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -974,7 +974,8 @@ intersect_ranges (enum value_range_kind *vr0type,
}
else if ((operand_less_p (vr1min, *vr0max) == 1
|| operand_equal_p (vr1min, *vr0max, 0))
- && operand_less_p (*vr0min, vr1min) == 1)
+ && operand_less_p (*vr0min, vr1min) == 1
+ && operand_less_p (*vr0max, vr1max) == 1)
{
/* [ ( ] ) or [ ]( ) */
if (*vr0type == VR_ANTI_RANGE
@@ -1008,7 +1009,8 @@ intersect_ranges (enum value_range_kind *vr0type,
}
else if ((operand_less_p (*vr0min, vr1max) == 1
|| operand_equal_p (*vr0min, vr1max, 0))
- && operand_less_p (vr1min, *vr0min) == 1)
+ && operand_less_p (vr1min, *vr0min) == 1
+ && operand_less_p (vr1max, *vr0max) == 1)
{
/* ( [ ) ] or ( )[ ] */
if (*vr0type == VR_ANTI_RANGE