[llvm] [DAGCombiner] Fix type check in visitSRA: use VT for SIGN_EXTEND and TruncVT for TRUNCATE (PR #157580)
Stephen Young via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 8 22:49:07 PDT 2025
https://github.com/StephenYoung2754 updated https://github.com/llvm/llvm-project/pull/157580
>From beb4a8b1c4057bf77dc5510abdad51a7ac46efcc Mon Sep 17 00:00:00 2001
From: Stephen Young <stephenyoung2754 at outlook.com>
Date: Mon, 8 Sep 2025 20:20:19 +0800
Subject: [PATCH] [DAGCombiner] Fix type check in visitSRA: use VT for
SIGN_EXTEND and TruncVT for TRUNCATE
---
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index d130efe96b56b..6a3865b579e41 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -10888,16 +10888,16 @@ SDValue DAGCombiner::visitSRA(SDNode *N) {
// on that type, and the truncate to that type is both legal and free,
// perform the transform.
if ((ShiftAmt > 0) &&
- TLI.isOperationLegalOrCustom(ISD::SIGN_EXTEND, TruncVT) &&
- TLI.isOperationLegalOrCustom(ISD::TRUNCATE, VT) &&
+ TLI.isOperationLegalOrCustom(ISD::SIGN_EXTEND, VT) &&
+ TLI.isOperationLegalOrCustom(ISD::TRUNCATE, TruncVT) &&
TLI.isTruncateFree(VT, TruncVT)) {
- SDValue Amt = DAG.getShiftAmountConstant(ShiftAmt, VT, DL);
- SDValue Shift = DAG.getNode(ISD::SRL, DL, VT,
- N0.getOperand(0), Amt);
- SDValue Trunc = DAG.getNode(ISD::TRUNCATE, DL, TruncVT,
- Shift);
- return DAG.getNode(ISD::SIGN_EXTEND, DL,
- N->getValueType(0), Trunc);
+ SDValue Amt = DAG.getShiftAmountConstant(ShiftAmt, VT, DL);
+ SDValue Shift = DAG.getNode(ISD::SRL, DL, VT,
+ N0.getOperand(0), Amt);
+ SDValue Trunc = DAG.getNode(ISD::TRUNCATE, DL, TruncVT,
+ Shift);
+ return DAG.getNode(ISD::SIGN_EXTEND, DL,
+ N->getValueType(0), Trunc);
}
}
}
More information about the llvm-commits
mailing list