This patch adds an option to specify the maximum depth in a BB at which to consider hoisting instructions.
Hoisting instructions from a deeper level is not profitable as it increases register pressure and compilation time.
Details
Diff Detail
Event Timeline
Two things:
- I'd rather not add knobs till we have to. So far, i didn't see that the compile time is being hurt once the other issue is fixed.
Am i missing something?
- Assuming i missed something and we want to do that, do you have any data on how this magic number affects performance at different numbers?
IE do you have any data that says "100" is right?
It would be ideal to have some data that says:
"at 0, we get no benefit
at 10, we get x benefit and no regressions
..
at 10000, we get x benefit and x regressions"
or something that gives us an idea that "100" is the right knob.
Data from compiling the test-suite for x86_64-linux with -mllvm -stats and varying the flag:
from the RegAlloc metrics we see that the minimum number of spills occurs for 100 and starts increasing back at 125.
-gvn-hoist-max-depth=0:
Number of rematerialized defs for spilling: 18286
Number of rematerialized defs for splitting: 5727
Number of spill slots allocated: 44014
Number of spilled live ranges: 62657
Number of spills inserted: 51753
gvn-hoist.*: 0
-gvn-hoist-max-depth=50:
Number of rematerialized defs for spilling: 18213
Number of rematerialized defs for splitting: 5827
Number of spill slots allocated: 43956
Number of spilled live ranges: 62539
Number of spills inserted: 51643
gvn-hoist.*Number of instructions hoisted: 21564
gvn-hoist.*Number of instructions removed: 30019
gvn-hoist.*Number of loads hoisted: 14697
gvn-hoist.*Number of loads removed: 20247
gvn-hoist.*Number of stores hoisted: 15
gvn-hoist.*Number of stores removed: 15
gvn-hoist.*Number of calls hoisted: 8
gvn-hoist.*Number of calls removed: 8
-gvn-hoist-max-depth=100:
Number of rematerialized defs for spilling: 18223
Number of rematerialized defs for splitting: 5817
Number of spill slots allocated: 43961
Number of spilled live ranges: 62521
Number of spills inserted: 51623
gvn-hoist.*Number of instructions hoisted: 21941
gvn-hoist.*Number of instructions removed: 31106
gvn-hoist.*Number of loads hoisted: 14951
gvn-hoist.*Number of loads removed: 21063
gvn-hoist.*Number of stores hoisted: 15
gvn-hoist.*Number of stores removed: 15
gvn-hoist.*Number of calls hoisted: 8
gvn-hoist.*Number of calls removed: 8
-gvn-hoist-max-depth=125:
Number of rematerialized defs for spilling: 18223
Number of rematerialized defs for splitting: 5817
Number of spill slots allocated: 43969
Number of spilled live ranges: 62520
Number of spills inserted: 51632
gvn-hoist.*Number of instructions hoisted: 22044
gvn-hoist.*Number of instructions removed: 31308
gvn-hoist.*Number of loads hoisted: 15034
gvn-hoist.*Number of loads removed: 21221
gvn-hoist.*Number of stores hoisted: 15
gvn-hoist.*Number of stores removed: 15
gvn-hoist.*Number of calls hoisted: 8
gvn-hoist.*Number of calls removed: 8
-gvn-hoist-max-depth=150:
Number of rematerialized defs for spilling: 18223
Number of rematerialized defs for splitting: 5817
Number of spill slots allocated: 43970
Number of spilled live ranges: 62516
Number of spills inserted: 51627
gvn-hoist.*Number of instructions hoisted: 22128
gvn-hoist.*Number of instructions removed: 31467
gvn-hoist.*Number of loads hoisted: 15086
gvn-hoist.*Number of loads removed: 21322
gvn-hoist.*Number of stores hoisted: 15
gvn-hoist.*Number of stores removed: 15
gvn-hoist.*Number of calls hoisted: 8
gvn-hoist.*Number of calls removed: 8
-gvn-hoist-max-depth=200:
Number of rematerialized defs for spilling: 18223
Number of rematerialized defs for splitting: 5817
Number of spill slots allocated: 43993
Number of spilled live ranges: 62552
Number of spills inserted: 51661
gvn-hoist.*Number of instructions hoisted: 22348
gvn-hoist.*Number of instructions removed: 31864
gvn-hoist.*Number of loads hoisted: 15200
gvn-hoist.*Number of loads removed: 21542
gvn-hoist.*Number of stores hoisted: 15
gvn-hoist.*Number of stores removed: 15
gvn-hoist.*Number of calls hoisted: 8
gvn-hoist.*Number of calls removed: 8
-gvn-hoist-max-depth=-1: (i.e., no bounds)
Number of rematerialized defs for spilling: 18244
Number of rematerialized defs for splitting: 5817
Number of spill slots allocated: 44070
Number of spilled live ranges: 62619
Number of spills inserted: 51740
gvn-hoist.*Number of instructions hoisted: 22508
gvn-hoist.*Number of instructions removed: 32925
gvn-hoist.*Number of loads hoisted: 15239
gvn-hoist.*Number of loads removed: 22004
gvn-hoist.*Number of stores hoisted: 15
gvn-hoist.*Number of stores removed: 15
gvn-hoist.*Number of calls hoisted: 8
gvn-hoist.*Number of calls removed: 8