[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
Tue Mar 30 15:12:57 PDT 2021
arsenm updated this revision to Diff 334281.
arsenm added a comment.
Fix being totally wrong
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99541/new/
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,9 +5350,16 @@
bool IsFSHL = MI.getOpcode() == TargetOpcode::G_FSHL;
unsigned RevOpcode = IsFSHL ? TargetOpcode::G_FSHR : TargetOpcode::G_FSHL;
+
+ // TODO: Use smarter heuristic that accounts for vector legalization.
if (LI.getAction({RevOpcode, {Ty, ShTy}}).Action == Lower)
return lowerFunnelShiftAsShifts(MI);
- return lowerFunnelShiftWithInverse(MI);
+
+ // This only works for powers of 2, fallback to shifts if it fails.
+ LegalizerHelper::LegalizeResult Result = lowerFunnelShiftWithInverse(MI);
+ if (Result == UnableToLegalize)
+ return lowerFunnelShiftAsShifts(MI);
+ return Result;
}
// Expand s32 = G_UITOFP s64 using bit operations to an IEEE float
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99541.334281.patch
Type: text/x-patch
Size: 1229 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210330/142bb70b/attachment.bin>
More information about the llvm-commits
mailing list