llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.9k stars 11.51k forks source link

[Subreg liveness] Enabling subreg liveness increases spilling significantly #40687

Open JonPsson opened 5 years ago

JonPsson commented 5 years ago
Bugzilla Link 41342
Version trunk
OS Linux
Attachments unreduced test case, llc input, reduced testcase
CC @kparzysz-quic,@JonPsson,@qcolombet,@uweigand

Extended Description

I found that the bzip2 benchmark regressed slightly when enabling subreg liveness due to one particular function (decompress). It seems that for some reason subreg liveness increases spilling instead of decreasing it:

./bin/llc -mtriple=s390x-linux-gnu -mcpu=z13 ./decompress.ll -o out.s --stats |& grep spill 1 regalloc - Number of rematerialized defs for spilling 9 regalloc - Number of spilled snippets 30 regalloc - Number of spill slots allocated 79 regalloc - Number of spilled live ranges 128 regalloc - Number of spills inserted 21 regalloc - Number of spills removed

./bin/llc -mtriple=s390x-linux-gnu -mcpu=z13 ./decompress.ll -o out.subr.s -systemz-subreg-liveness --stats |& grep spill 1 regalloc - Number of rematerialized defs for spilling 25 regalloc - Number of spilled snippets 27 regalloc - Number of spill slots allocated 168 regalloc - Number of spilled live ranges 173 regalloc - Number of spills inserted 149 regalloc - Number of spills removed

I made a reduced test case also from this file:

./bin/llc -mtriple=s390x-linux-gnu -mcpu=z13 ./tc_decompress_reduced.ll -o out.subr.s --stats |& grep spill 9 regalloc - Number of spill slots allocated 9 regalloc - Number of spilled live ranges 10 regalloc - Number of spills inserted

./bin/llc -mtriple=s390x-linux-gnu -mcpu=z13 ./tc_decompress_reduced.ll -o out.subr.s -systemz-subreg-liveness --stats |& grep spill 2 regalloc - Number of spilled snippets 11 regalloc - Number of spill slots allocated 11 regalloc - Number of spilled live ranges 13 regalloc - Number of spills inserted

I wonder if anyone might be able to help me in understanding why this happens?

qcolombet commented 5 years ago

(In particular, the number of spill slots is close in both cases so I am guessing/hoping this is just better placement.)

qcolombet commented 5 years ago

Is the spill cost bigger?

Essentially what I am wondering is whether we don't end up inserting more instructions but at cheaper places, which would be expected.