[llvm] [SelectionDAG] Fix zext assertion check for scalable vectors (PR #176064)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 14 16:13:37 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-aarch64
Author: Manasij Mukherjee (manasij7479)
<details>
<summary>Changes</summary>
Use element type comparisons in getZeroExtendInReg to avoid comparing scalable and fixed types.
Fixes #<!-- -->176037
---
Full diff: https://github.com/llvm/llvm-project/pull/176064.diff
2 Files Affected:
- (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (+6-2)
- (added) llvm/test/CodeGen/AArch64/aarch64-sve-setcc-promote-nxv8i8-crash.ll (+20)
``````````diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 80db53f02ba83..ac266d0630a6e 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -1574,7 +1574,10 @@ SDValue SelectionDAG::getZeroExtendInReg(SDValue Op, const SDLoc &DL, EVT VT) {
return Op;
// TODO: Use computeKnownBits instead of AssertZext.
if (Op.getOpcode() == ISD::AssertZext &&
- cast<VTSDNode>(Op.getOperand(1))->getVT().bitsLE(VT))
+ cast<VTSDNode>(Op.getOperand(1))
+ ->getVT()
+ .getScalarType()
+ .bitsLE(VT.getScalarType()))
return Op;
APInt Imm = APInt::getLowBitsSet(OpVT.getScalarSizeInBits(),
VT.getScalarSizeInBits());
@@ -1591,7 +1594,8 @@ SDValue SelectionDAG::getVPZeroExtendInReg(SDValue Op, SDValue Mask,
"getVPZeroExtendInReg type and operand type should be vector!");
assert(VT.getVectorElementCount() == OpVT.getVectorElementCount() &&
"Vector element counts must match in getZeroExtendInReg");
- assert(VT.bitsLE(OpVT) && "Not extending!");
+ assert(VT.getScalarType().bitsLE(OpVT.getScalarType()) &&
+ "Not extending!");
if (OpVT == VT)
return Op;
APInt Imm = APInt::getLowBitsSet(OpVT.getScalarSizeInBits(),
diff --git a/llvm/test/CodeGen/AArch64/aarch64-sve-setcc-promote-nxv8i8-crash.ll b/llvm/test/CodeGen/AArch64/aarch64-sve-setcc-promote-nxv8i8-crash.ll
new file mode 100644
index 0000000000000..dce9074b04523
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/aarch64-sve-setcc-promote-nxv8i8-crash.ll
@@ -0,0 +1,20 @@
+; RUN: llc -mtriple=aarch64-unknown-linux-gnu -mattr=+sve -o - %s | FileCheck %s
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32"
+target triple = "aarch64-unknown-linux-gnu"
+
+; Just check that llc does not crash
+define { ptr, i64 } @sve_setcc_promote_nxv8i8_crash(ptr %0, <vscale x 8 x i8> %1, <vscale x 8 x i8> %2) #0 {
+; CHECK-LABEL: sve_setcc_promote_nxv8i8_crash:
+iter.check:
+ %wide.load61.pre = load <vscale x 8 x i8>, ptr null, align 1
+ br label %vec.epilog.vector.body
+
+vec.epilog.vector.body: ; preds = %vec.epilog.vector.body, %iter.check
+ %3 = icmp eq <vscale x 8 x i8> %wide.load61.pre, zeroinitializer
+ %4 = select <vscale x 8 x i1> %3, <vscale x 8 x i8> zeroinitializer, <vscale x 8 x i8> %1
+ store <vscale x 8 x i8> %4, ptr %0, align 1
+ br label %vec.epilog.vector.body
+}
+
+attributes #0 = { "target-cpu"="neoverse-v2" }
``````````
</details>
https://github.com/llvm/llvm-project/pull/176064
More information about the llvm-commits
mailing list