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.
Paths
| Differential D97731
[AArch64][GlobalISel] Lower G_BUILD_VECTOR -> G_DUP ClosedPublic Authored by paquette on Mar 1 2021, 1:51 PM.
Details
Summary 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 TimelineHerald added subscribers: danielkiss, hiraditya, kristof.beyls, rovka. · View Herald TranscriptMar 1 2021, 1:51 PM paquette retitled this revision from [AArch64][GlobalISel] Lower G_BUILD_VECTOR -> G_DUP for non-constant splats to [AArch64][GlobalISel] Lower G_BUILD_VECTOR -> G_DUP.
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.
This revision is now accepted and ready to land.Mar 8 2021, 11:08 AM This revision was landed with ongoing or failed builds.Mar 8 2021, 1:02 PM Closed by commit rG5c26be214d9f: [AArch64][GlobalISel] Lower G_BUILD_VECTOR -> G_DUP (authored by paquette). · Explain Why This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 329116 llvm/include/llvm/CodeGen/GlobalISel/Utils.h
llvm/lib/CodeGen/GlobalISel/Utils.cpp
llvm/lib/Target/AArch64/AArch64Combine.td
llvm/lib/Target/AArch64/CMakeLists.txt
llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.hllvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerLowering.cpp
llvm/test/CodeGen/AArch64/GlobalISel/postlegalizer-lowering-build-vector-to-dup.mir
llvm/test/CodeGen/AArch64/GlobalISel/postlegalizer-lowering-vashr-vlshr.mir
llvm/test/CodeGen/AArch64/GlobalISel/select-dup.mir
llvm/test/CodeGen/AArch64/GlobalISel/select-vector-shift.mir
|
A quick comment to explain what this is for would be helpful. I also think we have the space to fully spell out Constant in the type.