[llvm] 9ad6049 - [InstCombine][SVE] Skip scalable type for InstCombiner::getFlippedStrictnessPredicateAndConstant.
Huihui Zhang via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 18 11:26:49 PDT 2020
Author: Huihui Zhang
Date: 2020-09-18T11:26:36-07:00
New Revision: 9ad6049736c58cca098b13ed128e7de0940f94a0
URL: https://github.com/llvm/llvm-project/commit/9ad6049736c58cca098b13ed128e7de0940f94a0
DIFF: https://github.com/llvm/llvm-project/commit/9ad6049736c58cca098b13ed128e7de0940f94a0.diff
LOG: [InstCombine][SVE] Skip scalable type for InstCombiner::getFlippedStrictnessPredicateAndConstant.
We cannot iterate on scalable vector, the number of elements is unknown at compile-time.
Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D87918
Added:
llvm/test/Transforms/InstCombine/vscale_cmp.ll
Modified:
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 74e9525e8ed4..a0b4c2216cca 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -5260,8 +5260,8 @@ InstCombiner::getFlippedStrictnessPredicateAndConstant(CmpInst::Predicate Pred,
// Bail out if the constant can't be safely incremented/decremented.
if (!ConstantIsOk(CI))
return llvm::None;
- } else if (auto *VTy = dyn_cast<VectorType>(Type)) {
- unsigned NumElts = cast<FixedVectorType>(VTy)->getNumElements();
+ } else if (auto *FVTy = dyn_cast<FixedVectorType>(Type)) {
+ unsigned NumElts = FVTy->getNumElements();
for (unsigned i = 0; i != NumElts; ++i) {
Constant *Elt = C->getAggregateElement(i);
if (!Elt)
diff --git a/llvm/test/Transforms/InstCombine/vscale_cmp.ll b/llvm/test/Transforms/InstCombine/vscale_cmp.ll
new file mode 100644
index 000000000000..bbceab06e3fc
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/vscale_cmp.ll
@@ -0,0 +1,11 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+define <vscale x 2 x i1> @sge(<vscale x 2 x i8> %x) {
+; CHECK-LABEL: @sge(
+; CHECK-NEXT: [[CMP:%.*]] = icmp sge <vscale x 2 x i8> [[X:%.*]], zeroinitializer
+; CHECK-NEXT: ret <vscale x 2 x i1> [[CMP]]
+;
+ %cmp = icmp sge <vscale x 2 x i8> %x, zeroinitializer
+ ret <vscale x 2 x i1> %cmp
+}
More information about the llvm-commits
mailing list