Skip to content

Commit 79d1708

Browse files
committed
[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: #99411
1 parent 35712db commit 79d1708

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11850,8 +11850,7 @@ class BoUpSLP::ShuffleInstructionBuilder final : public BaseShuffleAnalysis {
1185011850
Value *castToScalarTyElem(Value *V,
1185111851
std::optional<bool> IsSigned = std::nullopt) {
1185211852
auto *VecTy = cast<VectorType>(V->getType());
11853-
assert(getNumElements(ScalarTy) < getNumElements(VecTy) &&
11854-
(getNumElements(VecTy) % getNumElements(ScalarTy) == 0));
11853+
assert(getNumElements(VecTy) % getNumElements(ScalarTy) == 0);
1185511854
if (VecTy->getElementType() == ScalarTy->getScalarType())
1185611855
return V;
1185711856
return Builder.CreateIntCast(

llvm/test/Transforms/SLPVectorizer/revec-fix-99411.ll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
; RUN: opt -mtriple x86_64-unknown-linux-gnu -passes=slp-vectorizer -S %s | FileCheck %s
33

44
define void @e() {
5+
; CHECK-LABEL: @e(
6+
; CHECK-NEXT: entry:
7+
; CHECK-NEXT: store <2 x i64> zeroinitializer, ptr null, align 8
8+
; CHECK-NEXT: ret void
9+
;
510
entry:
611
%0 = extractelement <1 x i64> zeroinitializer, i64 0
712
%bf.value = and i64 %0, 0

0 commit comments

Comments
 (0)