If we have
%vec = G_BUILD_VECTOR %reg, %reg, ..., %reg
Then lower it to
%vec = G_DUP %reg
Also update the selector to handle constant splats on G_DUP.
Minor code size improvements on CTMark at -Os.
Differential D97731
[AArch64][GlobalISel] Lower G_BUILD_VECTOR -> G_DUP paquette on Mar 1 2021, 1:51 PM. Authored by
Details
If we have %vec = G_BUILD_VECTOR %reg, %reg, ..., %reg Then lower it to %vec = G_DUP %reg Also update the selector to handle constant splats on G_DUP. Minor code size improvements on CTMark at -Os.
Diff Detail Event Timeline
Comment Actions
(There's one place where the helper might make some difference, since getBuildVectorConstantSplat doesn't look through constants.) Comment Actions Looks like this blocks selecting vector neg since we miss some imported patterns. E.g. // (sub:{ *:[v2i32] } immAllZerosV:{ *:[v2i32] }, V64:{ *:[v2i32] }:$Rn) => (NEGv2i32:{ *:[v2i32] } V64:{ *:[v2i32] }:$Rn) Is there any way to get a G_DUP with 0 to match here? Comment Actions :( I don't see any easy way. You could maybe replicate the patterns that use immAllZeroesV to have a variant that uses AArch64dup but that doesn't seem like the right approach. I guess we have to avoid using this for constants in the absence of a better idea. Comment Actions This time, disallow 0 and 1 specifically. I think there are some DUP combines we're going to want. If 90% of the time it's better to represent this as DUP, I think it's probably better to prefer that. Also improve the helpers a little bit. I figured it'd be nice to have a general helper which gives you either a constant or a register for the dup matching.
|
I think we should this be a helper class and live in some AArch64 specific utils somewhere. We should programmatically have a single query to test for a splat operation.