[PATCH] D120531: [SystemZ] Use VREP for storing replicated regs/immediates.
Jonas Paulsson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 7 07:58:32 PST 2022
jonpa updated this revision to Diff 413483.
jonpa added a comment.
Patch updated to use SystemZVectorConstantInfo to detect the constant splats in combineSTORE().
If we were to only handle replicated constants / registers, it seems quite straightforward to simply build a splatVector in combineSTORE() and be done.
There are however also other constants that SystemZVectorConstantInfo can handle (with VGBM / VGM), which I have experimented with. The handling of stores of constants is in this version done instead in SystemZISelDAGToDAG.cpp, where Select() detects the case and loadVectorConstant() builds the vector with a vector element extraction. The experimental option '-replicate-only' skips generation of the non-REPLICATE opcodes, which should then show the value of being able to generate any vector constant.
**trunk <> patch "replicate only":**
This is the important part of the patch I think, as it eliminates the scalar multiplies (common case seems to be load-replicate-store):
vlrepb : 187 489 +302
llc : 39073 38772 -301
mhi : 6119 5851 -268
msfi : 7066 6934 -132
msgrkc : 7116 7071 -45
msgc : 407 403 -4
Generally it looks like a good change:
stef : 5750 6386 +636
vsteg : 5912 6475 +563
stg : 373052 372504 -548
st : 123399 122875 -524
vrepif : 7708 8127 +419
llihl : 7344 7022 -322
oill : 18487 18169 -318
vsteh : 2557 2875 +318
iilf : 5388 5108 -280
sth : 25810 25532 -278
lay : 54928 55179 +251
vrepih : 1131 1374 +243
sty : 3642 3527 -115
oilf : 9138 9048 -90
llihf : 11328 11238 -90
OPCDIFFS: -534
Spill|Reload : 613545 613472 -73
Copies : 1005714 1005692 -22
**patch "replicate only" <> patch "with vgbm/vgm":**
There seems to be many cases where this could be enabled:
vsteg : 6475 8912 +2437
stg : 372504 370085 -2419
vstef : 6386 8551 +2165
st : 122875 121122 -1753
vgmf : 13118 14454 +1336
vgmg : 8171 9496 +1325
llilh : 6887 5763 -1124
llihh : 2516 1662 -854
llihl : 7022 6564 -458
lg : 986019 986363 +344
l : 179157 179407 +250
stfh : 21086 20837 -249
vgbm : 10985 11189 +204
oilh : 1533 1341 -192
llihf : 11238 11063 -175
oilf : 9048 8909 -139
iilf : 5108 4974 -134
iihf : 4940 4837 -103
cg : 32046 32139 +93
OPCDIFFS: 554
Spill|Reload : 613472 614178 +706
Copies : 1005692 1005667 -25
The increase in spill/reload instructions seems to be due to one file with some +816 of them. I checked and have so far learned that it was not more vector register spills due to the constants being loaded into them, and it also seems that there are many more reloads, but not spills. This file is quite big, so it may be that the change is not that much relatively greater than in other smaller files.
One advantage with handling this in Select() (or rather after legalize-types), is that i128 constants now actually get handled - see @fun_128i. Not sure if that is of any real interest...
> I agree that this looks like the right thing to do. However, this really should use the SystemZVectorConstantInfo mechanism. (You'll probably have to add an APInt constructor there in addition to the APFloat one - currently this is only used for floating-point and vector constants, but now we also need it for integer constants. But that should be straightforward.)
Per above we could either just handle the replication of regs/constants in combineSTORE(), or if we would like to be able to use vgbm/vgm also for storing integer constants we can extend also Select(), but perhaps also try again to figure out why one file gets more reloading (f510.parest_r/build/vectors.s)...
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120531/new/
https://reviews.llvm.org/D120531
Files:
llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
llvm/lib/Target/SystemZ/SystemZISelLowering.h
llvm/test/CodeGen/SystemZ/store-replicated-vals.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120531.413483.patch
Type: text/x-patch
Size: 21483 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220307/9d611cb5/attachment.bin>
More information about the llvm-commits
mailing list