aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2022-01-10 13:33:44 -0500
committerAndrew MacLeod <amacleod@redhat.com>2022-01-11 09:21:12 -0500
commit71b72132011a47a4b39950d95718f18d1218978c (patch)
tree4aba44f3eb45991a4c9a255e32babd12ac8e0cc0
parent4f34f8cc1d064bfaaed723312c71e92f495d429b (diff)
downloadgcc-71b72132011a47a4b39950d95718f18d1218978c.zip
gcc-71b72132011a47a4b39950d95718f18d1218978c.tar.gz
gcc-71b72132011a47a4b39950d95718f18d1218978c.tar.bz2
Prevent exponential range calculations.
Produce a summary result for any operation involving too many subranges. PR tree-optimization/103821 * range-op.cc (range_operator::fold_range): Only do precise ranges when there are not too many subranges.
-rw-r--r--gcc/range-op.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 1af42eb..a4f6e9e 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -209,10 +209,12 @@ range_operator::fold_range (irange &r, tree type,
unsigned num_rh = rh.num_pairs ();
// If both ranges are single pairs, fold directly into the result range.
- if (num_lh == 1 && num_rh == 1)
+ // If the number of subranges grows too high, produce a summary result as the
+ // loop becomes exponential with little benefit. See PR 103821.
+ if ((num_lh == 1 && num_rh == 1) || num_lh * num_rh > 12)
{
- wi_fold_in_parts (r, type, lh.lower_bound (0), lh.upper_bound (0),
- rh.lower_bound (0), rh.upper_bound (0));
+ wi_fold_in_parts (r, type, lh.lower_bound (), lh.upper_bound (),
+ rh.lower_bound (), rh.upper_bound ());
op1_op2_relation_effect (r, type, lh, rh, rel);
return true;
}