[llvm] 88de933 - [ConstantFold][SVE] Fix constand fold for vector call.
Huihui Zhang via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 11 14:06:31 PST 2020
Author: Huihui Zhang
Date: 2020-02-11T14:06:15-08:00
New Revision: 88de9338f26c3c75001c17a5c4b71736e18fa0b6
URL: https://github.com/llvm/llvm-project/commit/88de9338f26c3c75001c17a5c4b71736e18fa0b6
DIFF: https://github.com/llvm/llvm-project/commit/88de9338f26c3c75001c17a5c4b71736e18fa0b6.diff
LOG: [ConstantFold][SVE] Fix constand fold for vector call.
Summary:
Do not iterate on scalable vectors.
Reviewers: sdesmalen, efriedma, apazos, huntergr, willlovett
Reviewed By: sdesmalen
Subscribers: tschuett, hiraditya, rkruppe, psnobl, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D74419
Added:
Modified:
llvm/lib/Analysis/ConstantFolding.cpp
llvm/test/Analysis/ConstantFolding/vscale.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 280a13ff1153..0ebc6a5919e8 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -2400,6 +2400,11 @@ static Constant *ConstantFoldVectorCall(StringRef Name,
SmallVector<Constant *, 4> Lane(Operands.size());
Type *Ty = VTy->getElementType();
+ // Do not iterate on scalable vector. The number of elements is unknown at
+ // compile-time.
+ if (VTy->getVectorIsScalable())
+ return nullptr;
+
if (IntrinsicID == Intrinsic::masked_load) {
auto *SrcPtr = Operands[0];
auto *Mask = Operands[2];
diff --git a/llvm/test/Analysis/ConstantFolding/vscale.ll b/llvm/test/Analysis/ConstantFolding/vscale.ll
index 2491308910df..3a3d6a16c7d6 100644
--- a/llvm/test/Analysis/ConstantFolding/vscale.ll
+++ b/llvm/test/Analysis/ConstantFolding/vscale.ll
@@ -210,3 +210,14 @@ define <vscale x 4 x i32> @select() {
%r = select <vscale x 4 x i1> undef, <vscale x 4 x i32> zeroinitializer, <vscale x 4 x i32> undef
ret <vscale x 4 x i32> %r
}
+
+declare <vscale x 16 x i8> @llvm.sadd.sat.nxv16i8(<vscale x 16 x i8>, <vscale x 16 x i8>)
+
+define <vscale x 16 x i8> @call() {
+; CHECK-LABEL: @call(
+; CHECK-NEXT: [[R:%.*]] = call <vscale x 16 x i8> @llvm.sadd.sat.nxv16i8(<vscale x 16 x i8> undef, <vscale x 16 x i8> undef)
+; CHECK-NEXT: ret <vscale x 16 x i8> [[R]]
+;
+ %r = call <vscale x 16 x i8> @llvm.sadd.sat.nxv16i8(<vscale x 16 x i8> undef, <vscale x 16 x i8> undef)
+ ret <vscale x 16 x i8> %r
+}
More information about the llvm-commits
mailing list