From 9ad6049736c58cca098b13ed128e7de0940f94a0 Mon Sep 17 00:00:00 2001 From: Huihui Zhang Date: Fri, 18 Sep 2020 11:26:28 -0700 Subject: [PATCH] [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 --- llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 4 ++-- llvm/test/Transforms/InstCombine/vscale_cmp.ll | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 llvm/test/Transforms/InstCombine/vscale_cmp.ll diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index 74e9525..a0b4c221 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(Type)) { - unsigned NumElts = cast(VTy)->getNumElements(); + } else if (auto *FVTy = dyn_cast(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 0000000..bbceab0 --- /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 @sge( %x) { +; CHECK-LABEL: @sge( +; CHECK-NEXT: [[CMP:%.*]] = icmp sge [[X:%.*]], zeroinitializer +; CHECK-NEXT: ret [[CMP]] +; + %cmp = icmp sge %x, zeroinitializer + ret %cmp +} -- 2.7.4