Skip to content

Commit b634e05

Browse files
authored
[SLP][REVEC] Fix false assumption of the source for castToScalarTyElem. (#99424)
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 cb3de24 commit b634e05

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11852,8 +11852,7 @@ class BoUpSLP::ShuffleInstructionBuilder final : public BaseShuffleAnalysis {
1185211852
Value *castToScalarTyElem(Value *V,
1185311853
std::optional<bool> IsSigned = std::nullopt) {
1185411854
auto *VecTy = cast<VectorType>(V->getType());
11855-
assert(getNumElements(ScalarTy) < getNumElements(VecTy) &&
11856-
(getNumElements(VecTy) % getNumElements(ScalarTy) == 0));
11855+
assert(getNumElements(VecTy) % getNumElements(ScalarTy) == 0);
1185711856
if (VecTy->getElementType() == ScalarTy->getScalarType())
1185811857
return V;
1185911858
return Builder.CreateIntCast(
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; RUN: opt -mtriple x86_64-unknown-linux-gnu -passes=slp-vectorizer -S %s | FileCheck %s
3+
4+
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+
;
10+
entry:
11+
%0 = extractelement <1 x i64> zeroinitializer, i64 0
12+
%bf.value = and i64 %0, 0
13+
%bf.set = or i64 0, %bf.value
14+
store i64 %bf.set, ptr getelementptr inbounds (i8, ptr null, i64 8), align 8
15+
%bf.value2 = and i64 0, 0
16+
%bf.set4 = or i64 0, %bf.value2
17+
store i64 %bf.set4, ptr null, align 8
18+
ret void
19+
}

0 commit comments

Comments
 (0)