aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Green <david.green@arm.com>2022-08-05 11:19:37 +0100
committerDavid Green <david.green@arm.com>2022-08-05 11:19:36 +0100
commitb2de84633a0a262b894e7cf87d29b167787aa2d6 (patch)
treed4087162c749f27988daba3222b6ec83879bf478
parentc401dbde71fdfdbdb0e77df54429408bab903991 (diff)
[ConstProp] Don't fallthorugh for poison constants on vctp and active_lane_mask.
Given a poison constant as input, the dyn_cast to a ConstantInt would fail so we would fall through to the generic code that attempts to fold each element of the input vectors. The inputs to these intrinsics are not vectors though, leading to a compile time crash. Instead bail out properly for poison values by returning nullptr. This doesn't try to define what poison means for these intrinsics. Fixes #56945
-rw-r--r--llvm/lib/Analysis/ConstantFolding.cpp4
-rw-r--r--llvm/test/Transforms/InstSimplify/ConstProp/ARM/mve-vctp.ll9
-rw-r--r--llvm/test/Transforms/InstSimplify/ConstProp/active-lane-mask.ll10
3 files changed, 18 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index f8d05eb688e3..38fb50347c30 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -3120,7 +3120,7 @@ static Constant *ConstantFoldFixedVectorCall(
}
return ConstantVector::get(NCs);
}
- break;
+ return nullptr;
}
case Intrinsic::get_active_lane_mask: {
auto *Op0 = dyn_cast<ConstantInt>(Operands[0]);
@@ -3139,7 +3139,7 @@ static Constant *ConstantFoldFixedVectorCall(
}
return ConstantVector::get(NCs);
}
- break;
+ return nullptr;
}
default:
break;
diff --git a/llvm/test/Transforms/InstSimplify/ConstProp/ARM/mve-vctp.ll b/llvm/test/Transforms/InstSimplify/ConstProp/ARM/mve-vctp.ll
index 34aea14b594c..979fb2e84ba9 100644
--- a/llvm/test/Transforms/InstSimplify/ConstProp/ARM/mve-vctp.ll
+++ b/llvm/test/Transforms/InstSimplify/ConstProp/ARM/mve-vctp.ll
@@ -259,7 +259,14 @@ entry:
ret <2 x i1> %int
}
-
+define <4 x float> @poisonc(<4 x float> %a) {
+entry:
+ %new0 = shl i1 0, 1
+ %last = zext i1 %new0 to i32
+ %var27 = call <4 x i1> @llvm.arm.mve.vctp32(i32 %last)
+ %var33 = select <4 x i1> %var27, <4 x float> %a, <4 x float> zeroinitializer
+ ret <4 x float> %var33
+}
declare <2 x i1> @llvm.arm.mve.vctp64(i32)
declare <4 x i1> @llvm.arm.mve.vctp32(i32)
diff --git a/llvm/test/Transforms/InstSimplify/ConstProp/active-lane-mask.ll b/llvm/test/Transforms/InstSimplify/ConstProp/active-lane-mask.ll
index 726038122289..4a879e837f83 100644
--- a/llvm/test/Transforms/InstSimplify/ConstProp/active-lane-mask.ll
+++ b/llvm/test/Transforms/InstSimplify/ConstProp/active-lane-mask.ll
@@ -292,8 +292,14 @@ entry:
}
-
-
+define <4 x float> @poisonc(<4 x float> %a, i32 %n) {
+entry:
+ %new0 = shl i1 0, 1
+ %last = zext i1 %new0 to i32
+ %var27 = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 %last, i32 1024)
+ %var33 = select <4 x i1> %var27, <4 x float> %a, <4 x float> zeroinitializer
+ ret <4 x float> %var33
+}
declare <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32, i32)
declare <8 x i1> @llvm.get.active.lane.mask.v8i1.i32(i32, i32)