[llvm] [LegalizeTypes] Use getShiftAmountConstant in SplitInteger. (PR #158392)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 12 18:10:30 PDT 2025
https://github.com/topperc created https://github.com/llvm/llvm-project/pull/158392
This function contained old code for handling the case that the type returned getScalarShiftAmountTy can't hold the shift amount.
These days this is handled by getShiftAmountTy which is used by getShiftAmountConstant.
>From 3eb9f2540f2b80e6ba30549d5cd50b1740718f6e Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Fri, 12 Sep 2025 18:02:41 -0700
Subject: [PATCH] [LegalizeTypes] Use getShiftAmountConstant in SplitInteger.
This function contained old code for handling the case that the
type returned getScalarShiftAmountTy can't hold the shift amount.
These days this is handled by getShiftAmountTy which is used by
getShiftAmountConstant.
---
llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
index 83fade45d1892..cc0fd7993916c 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
@@ -1026,14 +1026,9 @@ void DAGTypeLegalizer::SplitInteger(SDValue Op,
assert(LoVT.getSizeInBits() + HiVT.getSizeInBits() ==
Op.getValueSizeInBits() && "Invalid integer splitting!");
Lo = DAG.getNode(ISD::TRUNCATE, dl, LoVT, Op);
- unsigned ReqShiftAmountInBits =
- Log2_32_Ceil(Op.getValueType().getSizeInBits());
- MVT ShiftAmountTy =
- TLI.getScalarShiftAmountTy(DAG.getDataLayout(), Op.getValueType());
- if (ReqShiftAmountInBits > ShiftAmountTy.getSizeInBits())
- ShiftAmountTy = MVT::getIntegerVT(NextPowerOf2(ReqShiftAmountInBits));
- Hi = DAG.getNode(ISD::SRL, dl, Op.getValueType(), Op,
- DAG.getConstant(LoVT.getSizeInBits(), dl, ShiftAmountTy));
+ Hi = DAG.getNode(
+ ISD::SRL, dl, Op.getValueType(), Op,
+ DAG.getShiftAmountConstant(LoVT.getSizeInBits(), Op.getValueType(), dl));
Hi = DAG.getNode(ISD::TRUNCATE, dl, HiVT, Hi);
}
More information about the llvm-commits
mailing list