diff options
author | David Green <david.green@arm.com> | 2022-08-05 11:19:37 +0100 |
---|---|---|
committer | Tom Stellard <tstellar@redhat.com> | 2022-08-08 12:22:10 -0700 |
commit | 0adb0f9a97c7cd6e6d315d533b4db452456ebe13 (patch) | |
tree | 4a69499682f292bed4e0f1afe8bbe77be5d99bbd | |
parent | bf956104334ac393e92d0655066ea971616a22d8 (diff) | |
download | llvm-0adb0f9a97c7cd6e6d315d533b4db452456ebe13.zip llvm-0adb0f9a97c7cd6e6d315d533b4db452456ebe13.tar.gz llvm-0adb0f9a97c7cd6e6d315d533b4db452456ebe13.tar.bz2 |
[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
(cherry picked from commit b2de84633a0a262b894e7cf87d29b167787aa2d6)
-rw-r--r-- | llvm/lib/Analysis/ConstantFolding.cpp | 4 | ||||
-rw-r--r-- | llvm/test/Transforms/InstSimplify/ConstProp/ARM/mve-vctp.ll | 9 | ||||
-rw-r--r-- | llvm/test/Transforms/InstSimplify/ConstProp/active-lane-mask.ll | 10 |
3 files changed, 18 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index aa4da27be..ae927da 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 34aea14..979fb2e 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 7260381..4a879e83 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) |