[PATCH] D99541: GlobalISel: Check for powers of 2 for inverse funnel shift lowering
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 29 14:28:14 PDT 2021
arsenm created this revision.
arsenm added reviewers: foad, aemerson, paquette.
Herald added subscribers: hiraditya, rovka.
arsenm requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.
This doesn't make a practical difference since it would only be broken
if a target actually had a legal non-power-of-2 inverse shift.
https://reviews.llvm.org/D99541
Files:
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
Index: llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
===================================================================
--- llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
+++ llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -5248,6 +5248,10 @@
LLT ShTy = MRI.getType(Z);
unsigned BW = Ty.getScalarSizeInBits();
+
+ if (!isPowerOf2_32(BW))
+ return UnableToLegalize;
+
const bool IsFSHL = MI.getOpcode() == TargetOpcode::G_FSHL;
unsigned RevOpcode = IsFSHL ? TargetOpcode::G_FSHR : TargetOpcode::G_FSHL;
@@ -5346,8 +5350,13 @@
bool IsFSHL = MI.getOpcode() == TargetOpcode::G_FSHL;
unsigned RevOpcode = IsFSHL ? TargetOpcode::G_FSHR : TargetOpcode::G_FSHL;
- if (LI.getAction({RevOpcode, {Ty, ShTy}}).Action == Lower)
- return lowerFunnelShiftAsShifts(MI);
+ if (LI.getAction({RevOpcode, {Ty, ShTy}}).Action == Lower) {
+ // This only works for powers of 2, fallback to shifts if it fails.
+ LegalizerHelper::LegalizeResult Result = lowerFunnelShiftAsShifts(MI);
+ if (Result != UnableToLegalize)
+ return Result;
+ }
+
return lowerFunnelShiftWithInverse(MI);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99541.333985.patch
Type: text/x-patch
Size: 1120 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210329/39adf257/attachment.bin>
More information about the llvm-commits
mailing list