public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-6477] Prevent exponential range calculations.
@ 2022-01-11 14:39 Andrew Macleod
  0 siblings, 0 replies; only message in thread
From: Andrew Macleod @ 2022-01-11 14:39 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:71b72132011a47a4b39950d95718f18d1218978c

commit r12-6477-g71b72132011a47a4b39950d95718f18d1218978c
Author: Andrew MacLeod <amacleod@redhat.com>
Date:   Mon Jan 10 13:33:44 2022 -0500

    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.

Diff:
---
 gcc/range-op.cc | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 1af42ebc376..a4f6e9eba29 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;
     }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-11 14:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-11 14:39 [gcc r12-6477] Prevent exponential range calculations Andrew Macleod

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).