[llvm] [SLP][REVEC] Fix false assumption of the source for castToScalarTyElem. (PR #99424)

Han-Kuan Chen via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 17 20:52:07 PDT 2024


https://github.com/HanKuanChen updated https://github.com/llvm/llvm-project/pull/99424

>From 049e1cc81fe7707abe8d0696ad4c0450bbd9e95e Mon Sep 17 00:00:00 2001
From: Han-Kuan Chen <hankuan.chen at sifive.com>
Date: Wed, 17 Jul 2024 20:35:42 -0700
Subject: [PATCH] [SLP][REVEC] Fix false assumption of the source for
 castToScalarTyElem.

The argument V may come from adjustExtracts, which is the vector operand
of ExtractElementInst. In addition, it is not existed in getTreeEntry.

The vector operand of ExtractElementInst may have a type of <1 x Ty>,
ensuring that the number of elements in ScalarTy and VecTy are equal.

reference: https://github.com/llvm/llvm-project/issues/99411
---
 llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index ccb6734d5618c..1201bed539505 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -11850,8 +11850,7 @@ class BoUpSLP::ShuffleInstructionBuilder final : public BaseShuffleAnalysis {
   Value *castToScalarTyElem(Value *V,
                             std::optional<bool> IsSigned = std::nullopt) {
     auto *VecTy = cast<VectorType>(V->getType());
-    assert(getNumElements(ScalarTy) < getNumElements(VecTy) &&
-           (getNumElements(VecTy) % getNumElements(ScalarTy) == 0));
+    assert(getNumElements(VecTy) % getNumElements(ScalarTy) == 0);
     if (VecTy->getElementType() == ScalarTy->getScalarType())
       return V;
     return Builder.CreateIntCast(



More information about the llvm-commits mailing list