* [PATCH] Don;t over allocate switch default clauses.
@ 2021-05-07 19:02 Andrew MacLeod
0 siblings, 0 replies; only message in thread
From: Andrew MacLeod @ 2021-05-07 19:02 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 267 bytes --]
We were always allocating the 255 max ranges for the default
condition. Instead, use int_range_max to build the default range,
then allocate and store only what is needed.
Bootstraps on x86_64-pc-linux-gnu with no testsuite regressions.
Pushed.
Andrew
[-- Attachment #2: 3-switch.patch --]
[-- Type: text/x-patch, Size: 1793 bytes --]
commit 57090307da6ff4378c84f768e2f2717095f712c1
Author: Andrew MacLeod <amacleod@redhat.com>
Date: Mon Apr 26 17:50:18 2021 -0400
Don't over-allocate switch default range object.
We were always allocating the 255 max ranges for the default condition.
Instead, use int_range_max to build the default range, then allocate and
store only what is needed.
* gimple-range-edge.cc (outgoing_range::calc_switch_ranges): Compute
default range into a temp and allocate only what is needed.
diff --git a/gcc/gimple-range-edge.cc b/gcc/gimple-range-edge.cc
index d2c7d384dff..4d4cb97bbec 100644
--- a/gcc/gimple-range-edge.cc
+++ b/gcc/gimple-range-edge.cc
@@ -112,8 +112,7 @@ outgoing_range::calc_switch_ranges (gswitch *sw)
//
// Allocate an int_range_max for the default range case, start with
// varying and intersect each other case from it.
- irange *default_range = m_range_allocator.allocate (255);
- default_range->set_varying (type);
+ int_range_max default_range (type);
for (x = 1; x < lim; x++)
{
@@ -132,7 +131,7 @@ outgoing_range::calc_switch_ranges (gswitch *sw)
int_range_max def_range (low, high);
range_cast (def_range, type);
def_range.invert ();
- default_range->intersect (def_range);
+ default_range.intersect (def_range);
// Create/union this case with anything on else on the edge.
int_range_max case_range (low, high);
@@ -156,7 +155,8 @@ outgoing_range::calc_switch_ranges (gswitch *sw)
irange *&slot = m_edge_table->get_or_insert (default_edge, &existed);
// This should be the first call into this switch.
gcc_checking_assert (!existed);
- slot = default_range;
+ irange *dr = m_range_allocator.allocate (default_range);
+ slot = dr;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-05-07 19:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-07 19:02 [PATCH] Don;t over allocate switch default clauses 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).