[llvm] a1fdcfa - [AArch64] Protect against scalar types in isNVCastToHalfWidthElements.
David Green via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 28 11:39:16 PST 2025
Author: David Green
Date: 2025-02-28T19:39:11Z
New Revision: a1fdcfa1ea8acc7493e45e9350108bc566044597
URL: https://github.com/llvm/llvm-project/commit/a1fdcfa1ea8acc7493e45e9350108bc566044597
DIFF: https://github.com/llvm/llvm-project/commit/a1fdcfa1ea8acc7493e45e9350108bc566044597.diff
LOG: [AArch64] Protect against scalar types in isNVCastToHalfWidthElements.
Fixes #129227
Added:
Modified:
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/test/CodeGen/AArch64/hadd-combine.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 7a471662ea075..babf240a911f4 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -23079,8 +23079,9 @@ static SDValue isNVCastToHalfWidthElements(SDValue V) {
return SDValue();
SDValue Op = V.getOperand(0);
- if (V.getValueType().getVectorElementCount() !=
- Op.getValueType().getVectorElementCount() * 2)
+ if (!Op.getValueType().isVector() ||
+ V.getValueType().getVectorElementCount() !=
+ Op.getValueType().getVectorElementCount() * 2)
return SDValue();
return Op;
diff --git a/llvm/test/CodeGen/AArch64/hadd-combine.ll b/llvm/test/CodeGen/AArch64/hadd-combine.ll
index 28f454767c121..58d958bca45ee 100644
--- a/llvm/test/CodeGen/AArch64/hadd-combine.ll
+++ b/llvm/test/CodeGen/AArch64/hadd-combine.ll
@@ -1020,6 +1020,19 @@ define <2 x i32> @srhadd_signbits_v2i32_negative(<2 x i32> %a0, <2 x i32> %a1, p
ret <2 x i32> %avg2
}
+define <8 x i8> @dontcrashonnvcasts() {
+; CHECK-LABEL: dontcrashonnvcasts:
+; CHECK: // %bb.0:
+; CHECK-NEXT: movi v0.2s, #128, lsl #24
+; CHECK-NEXT: movi v1.2d, #0000000000000000
+; CHECK-NEXT: fneg d0, d0
+; CHECK-NEXT: uzp1 v0.8b, v0.8b, v1.8b
+; CHECK-NEXT: ret
+ %vrhadd_v.i = tail call <8 x i8> @llvm.aarch64.neon.urhadd.v8i8(<8 x i8> <i8 0, i8 0, i8 0, i8 -1, i8 0, i8 0, i8 0, i8 0>, <8 x i8> zeroinitializer)
+ %shuffle.i = shufflevector <8 x i8> %vrhadd_v.i, <8 x i8> <i8 0, i8 poison, i8 0, i8 poison, i8 0, i8 poison, i8 0, i8 poison>, <8 x i32> <i32 0, i32 2, i32 4, i32 6, i32 8, i32 10, i32 12, i32 14>
+ ret <8 x i8> %shuffle.i
+}
+
declare <8 x i8> @llvm.aarch64.neon.shadd.v8i8(<8 x i8>, <8 x i8>)
declare <4 x i16> @llvm.aarch64.neon.shadd.v4i16(<4 x i16>, <4 x i16>)
declare <2 x i32> @llvm.aarch64.neon.shadd.v2i32(<2 x i32>, <2 x i32>)
More information about the llvm-commits
mailing list