[llvm] [Codegen][LegalizeIntegerTypes] Improve shift through stack (PR #96151)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 25 05:32:11 PDT 2024
================
@@ -4530,14 +4530,35 @@ void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(SDNode *N, SDValue &Lo,
SDValue ShAmt = N->getOperand(1);
EVT ShAmtVT = ShAmt.getValueType();
- // This legalization is optimal when the shift is by a multiple of byte width,
- // %x * 8 <-> %x << 3 so 3 low bits should be be known zero.
- bool ShiftByByteMultiple =
- DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >= 3;
+ EVT LoadStoreVT = VT;
+ do {
+ LoadStoreVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadStoreVT);
----------------
futog wrote:
`ExpandIntRes_ShiftThroughStack` is called only if the result must be expanded in at least two steps (See https://github.com/llvm/llvm-project/blob/0f111ba790a28056d42a0ae376371d7b694454ae/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp#L4668).
Also TargetLowering::isTypeLegal returns true if the target has native support for the specified value type.
On riscv32 for i128 shift it will loop.
https://github.com/llvm/llvm-project/pull/96151
More information about the llvm-commits
mailing list