[llvm] [LLVM][DAGTypeLegalizer] Maintain scalableness when widening inreg extends. (PR #192482)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 16 09:12:22 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-aarch64
Author: Paul Walker (paulwalker-arm)
<details>
<summary>Changes</summary>
Fixes https://github.com/llvm/llvm-project/issues/187557
---
Full diff: https://github.com/llvm/llvm-project/pull/192482.diff
2 Files Affected:
- (modified) llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (+4-4)
- (modified) llvm/test/CodeGen/AArch64/sve-sext-zext.ll (+11)
``````````diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
index a96c77bc6a4e9..f3ddb9e4b811e 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
@@ -6146,10 +6146,10 @@ SDValue DAGTypeLegalizer::WidenVecRes_Unary(SDNode *N) {
SDValue DAGTypeLegalizer::WidenVecRes_InregOp(SDNode *N) {
EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));
- EVT ExtVT = EVT::getVectorVT(*DAG.getContext(),
- cast<VTSDNode>(N->getOperand(1))->getVT()
- .getVectorElementType(),
- WidenVT.getVectorNumElements());
+ EVT ExtVT = EVT::getVectorVT(
+ *DAG.getContext(),
+ cast<VTSDNode>(N->getOperand(1))->getVT().getVectorElementType(),
+ WidenVT.getVectorElementCount());
SDValue WidenLHS = GetWidenedVector(N->getOperand(0));
return DAG.getNode(N->getOpcode(), SDLoc(N),
WidenVT, WidenLHS, DAG.getValueType(ExtVT));
diff --git a/llvm/test/CodeGen/AArch64/sve-sext-zext.ll b/llvm/test/CodeGen/AArch64/sve-sext-zext.ll
index 54dd83eaec507..f8713c370515d 100644
--- a/llvm/test/CodeGen/AArch64/sve-sext-zext.ll
+++ b/llvm/test/CodeGen/AArch64/sve-sext-zext.ll
@@ -612,3 +612,14 @@ define <vscale x 16 x i16> @sext_inreg_i2_to_i16_from_i8(<vscale x 16 x i8> %a)
%a.sextinreg = sext <vscale x 16 x i2> %a.trunc to <vscale x 16 x i16>
ret <vscale x 16 x i16> %a.sextinreg
}
+
+define <vscale x 7 x i16> @widen_sext_inreg_result(<vscale x 7 x i16> %a) {
+; CHECK-LABEL: widen_sext_inreg_result:
+; CHECK: // %bb.0:
+; CHECK-NEXT: ptrue p0.h
+; CHECK-NEXT: sxtb z0.h, p0/m, z0.h
+; CHECK-NEXT: ret
+ %a.trunc = trunc <vscale x 7 x i16> %a to <vscale x 7 x i8>
+ %a.sextinreg = sext <vscale x 7 x i8> %a.trunc to <vscale x 7 x i16>
+ ret <vscale x 7 x i16> %a.sextinreg
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/192482
More information about the llvm-commits
mailing list