public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Andrew Macleod <amacleod@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-6477] Prevent exponential range calculations. Date: Tue, 11 Jan 2022 14:39:29 +0000 (GMT) [thread overview] Message-ID: <20220111143929.3492B38AAC1A@sourceware.org> (raw) 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; }
reply other threads:[~2022-01-11 14:39 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220111143929.3492B38AAC1A@sourceware.org \ --to=amacleod@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).