[llvm] a6f751c - [AArch64][SVE] Fix ICE extracting fixedvec from scalable load
Peter Waller via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 6 08:50:04 PST 2021
Author: Peter Waller
Date: 2021-12-06T16:49:43Z
New Revision: a6f751c34ec1ead6fe94c5eea375307fc12a5359
URL: https://github.com/llvm/llvm-project/commit/a6f751c34ec1ead6fe94c5eea375307fc12a5359
DIFF: https://github.com/llvm/llvm-project/commit/a6f751c34ec1ead6fe94c5eea375307fc12a5359.diff
LOG: [AArch64][SVE] Fix ICE extracting fixedvec from scalable load
f526c600c043 had a concern raised because of an invalid typesize request
on a scalable vector, which this patch addresses.
Prevent shouldReduceLoadWidth from attempting to query the bit size, and
add a regression test in sve-extract-fixed-vector.ll.
Differential Revision: https://reviews.llvm.org/D115156
Added:
Modified:
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/test/CodeGen/AArch64/sve-extract-fixed-vector.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 72461aa1f772d..688bd6b2b1984 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -11794,6 +11794,9 @@ bool AArch64TargetLowering::shouldReduceLoadWidth(SDNode *Load,
Base.getOperand(1).getOpcode() == ISD::SHL &&
Base.getOperand(1).hasOneUse() &&
Base.getOperand(1).getOperand(1).getOpcode() == ISD::Constant) {
+ // It's unknown whether a scalable vector has a power-of-2 bitwidth.
+ if (Mem->getMemoryVT().isScalableVector())
+ return false;
// The shift can be combined if it matches the size of the value being
// loaded (and so reducing the width would make it not match).
uint64_t ShiftAmount = Base.getOperand(1).getConstantOperandVal(1);
diff --git a/llvm/test/CodeGen/AArch64/sve-extract-fixed-vector.ll b/llvm/test/CodeGen/AArch64/sve-extract-fixed-vector.ll
index 066c7f8002c1e..3be4b94dedd22 100644
--- a/llvm/test/CodeGen/AArch64/sve-extract-fixed-vector.ll
+++ b/llvm/test/CodeGen/AArch64/sve-extract-fixed-vector.ll
@@ -408,6 +408,22 @@ define <4 x i64> @extract_fixed_v4i64_nxv2i64(<vscale x 2 x i64> %vec) nounwind
ret <4 x i64> %retval
}
+; Check that extract from load via bitcast-gep-of-scalar-ptr does not crash.
+define <4 x i32> @typesize_regression_test_v4i32(i32* %addr, i64 %idx) {
+; CHECK-LABEL: typesize_regression_test_v4i32:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: ptrue p0.s
+; CHECK-NEXT: ld1w { z0.s }, p0/z, [x0, x1, lsl #2]
+; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0
+; CHECK-NEXT: ret
+entry:
+ %ptr = getelementptr inbounds i32, i32* %addr, i64 %idx
+ %bc = bitcast i32* %ptr to <vscale x 4 x i32>*
+ %ld = load <vscale x 4 x i32>, <vscale x 4 x i32>* %bc, align 16
+ %out = call <4 x i32> @llvm.experimental.vector.extract.v4i32.nxv4i32(<vscale x 4 x i32> %ld, i64 0)
+ ret <4 x i32> %out
+}
+
attributes #0 = { vscale_range(2,2) }
attributes #1 = { vscale_range(8,8) }
More information about the llvm-commits
mailing list