aboutsummaryrefslogtreecommitdiff
path: root/gcc/ira-costs.c
diff options
context:
space:
mode:
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2017-01-13 15:56:04 +0000
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2017-01-13 15:56:04 +0000
commiteb87bcd977cb33b02a0a9c6135a165dac3de7213 (patch)
tree929449609619b78f8928c5c255b6a6dacb0c58c6 /gcc/ira-costs.c
parent805aeef72026548bac3984a59825d7754664dac1 (diff)
Short-circuit alt_fail case in record_reg_classes
record_reg_classes is often the hottest function when generating unoptimised output. It seems typical for over 60% of the instructions it handles to be moves, and of course moves tend to be the instructions with the longest constraint strings. Maybe we should avoid using move constraints to set costs in unoptimised output and instead use the "natural" class for the mode being moved. That's too invasive for stage 3 though. However, seeing so many moves means that we see many "failing" alternatives, usually because of '*' or because of hard registers in function call sequences. The frequency of alternatives that are detected as failures after the first operand tends again to be more than 60%. Previously we would continue to process the other operands of the alternative regardless. This patch instead adds a short-cut. As well as avoiding unnecessary work, it means that the alt_fail variable can be jump-threaded away. Tested on aach64-linux-gnu and x86_64-linux-gnu. It reduces compile time by about 1% on some tests with "-g -O0". gcc/ * ira-costs.c (record_reg_classes): Break from the inner loop early once alt_fail is known to be true. Update outer loop handling accordingly. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@244446 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ira-costs.c')
-rw-r--r--gcc/ira-costs.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/gcc/ira-costs.c b/gcc/ira-costs.c
index 50d0c04764d..c3bddb7f7d0 100644
--- a/gcc/ira-costs.c
+++ b/gcc/ira-costs.c
@@ -820,6 +820,9 @@ record_reg_classes (int n_alts, int n_ops, rtx *ops,
constraints[i] = p;
+ if (alt_fail)
+ break;
+
/* How we account for this operand now depends on whether it
is a pseudo register or not. If it is, we first check if
any register classes are valid. If not, we ignore this
@@ -999,10 +1002,21 @@ record_reg_classes (int n_alts, int n_ops, rtx *ops,
alt_cost += ira_memory_move_cost[mode][classes[i]][1];
else
alt_fail = 1;
+
+ if (alt_fail)
+ break;
}
if (alt_fail)
- continue;
+ {
+ /* The loop above might have exited early once the failure
+ was seen. Skip over the constraints for the remaining
+ operands. */
+ i += 1;
+ for (; i < n_ops; ++i)
+ constraints[i] = skip_alternative (constraints[i]);
+ continue;
+ }
op_cost_add = alt_cost * frequency;
/* Finally, update the costs with the information we've