Skip to content

Conversation

topperc
Copy link
Collaborator

@topperc topperc commented Sep 13, 2025

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.

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.
@topperc topperc requested review from arsenm and RKSimon September 13, 2025 01:10
@llvmbot llvmbot added the llvm:SelectionDAG SelectionDAGISel as well label Sep 13, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 13, 2025

@llvm/pr-subscribers-llvm-selectiondag

Author: Craig Topper (topperc)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/158392.diff

1 Files Affected:

  • (modified) llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp (+3-8)
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);
 }
 

@topperc topperc merged commit 0ca54d7 into llvm:main Sep 13, 2025
11 checks passed
@topperc topperc deleted the pr/SplitInteger branch September 13, 2025 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm:SelectionDAG SelectionDAGISel as well
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants