This has a fairly good chance of killing off significant amounts of dead
code when narrowScalar() is used to legalize certain instructions since
it removes vestigial uses of the upper component of a G_MERGE_VALUES that
may not contribute to the final value. For example, a sequence of s128
operations narrowScalar'd to s64 that ends in a truncation to s64 can
discard all the operations for the upper s64. As they are no longer
kept alive by the use of the lower s64.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
- Build Status
Buildable 36568 Build 36567: arc lint + arc unit
Event Timeline
llvm/include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h | ||
---|---|---|
413 | Good point. I'd forgotten we had split vectors out |
Patch alone looks good.
I'm just coming from D61787, hopefully it shouldn't be to complicated to make them both work together.
Also targets does not have to define any legalization rules for this combine to work which is great.
In D61787 I mentioned that it might be easier for artifact combiner if this was handled with adding narrow scalar rule for G_TRUNC(G_UNMERGE+COPY) and allowing combiner to finish with combining G_UNMERGE/G_MERGE.
What do you think is better in the sense that we also want to allow legalization of chained artifacts?
Now we have G_SEXT/G_TRUNC combine and G_TRUNC/G_UNMERGE_VALUES, which one should happen first in a sequence like this?
%2:_(s128) = G_MERGE_VALUES %0:_(s64), %1:_(s64) %3:_(s64) = G_TRUNC %2(s128) %4:_(s128) = G_SEXT %3:_(s64) . . . = G_UNMERGE_VALUES %4:_(s128)
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-unmerge-values.mir | ||
---|---|---|
253–257 | Uncombined G_UNMERGE/G_MERGE pair. |
Rebase
Note: The addition of s128 G_LOAD/G_STORE to AArch64's made test_inserts_[123] from test/CodeGen/AArch64/GlobalISel/legalize-inserts.mir unusable so they are only tested in LegalizerArtifactCombinerTest.cpp now
No else after return