diff options
author | Alexey Bataev <a.bataev@outlook.com> | 2024-04-29 06:51:11 -0700 |
---|---|---|
committer | Alexey Bataev <a.bataev@outlook.com> | 2024-04-29 06:51:11 -0700 |
commit | 040b5a1255dba79f6e6819ac4864256127f810a0 (patch) | |
tree | 3f6ea55ec2a18c1a886bd40facca075a4da9db59 | |
parent | 86b9a4f892b9fc6cf5929f33a529570acd7abc71 (diff) | |
download | llvm-040b5a1255dba79f6e6819ac4864256127f810a0.zip llvm-040b5a1255dba79f6e6819ac4864256127f810a0.tar.gz llvm-040b5a1255dba79f6e6819ac4864256127f810a0.tar.bz2 |
[SLP]Fix PR90211: vectorized node must match completely to be reused.
If the gather node matches the vectorized node, it must also match with
the scalars completely. Otherwise, need to revectorize the gather node
to generate correct code.
-rw-r--r-- | llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 3 | ||||
-rw-r--r-- | llvm/test/Transforms/SLPVectorizer/X86/gather-node-same-as-vect-but-order.ll | 3 |
2 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index f62270f..2facd03 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -13166,7 +13166,8 @@ Value *BoUpSLP::vectorizeTree( auto *TE = const_cast<TreeEntry *>(E); if (auto *VecTE = getTreeEntry(TE->Scalars.front())) if (VecTE->isSame(TE->UserTreeIndices.front().UserTE->getOperand( - TE->UserTreeIndices.front().EdgeIdx))) + TE->UserTreeIndices.front().EdgeIdx)) && + VecTE->isSame(TE->Scalars)) // Found gather node which is absolutely the same as one of the // vectorized nodes. It may happen after reordering. continue; diff --git a/llvm/test/Transforms/SLPVectorizer/X86/gather-node-same-as-vect-but-order.ll b/llvm/test/Transforms/SLPVectorizer/X86/gather-node-same-as-vect-but-order.ll index e66d38b..d80d7b5 100644 --- a/llvm/test/Transforms/SLPVectorizer/X86/gather-node-same-as-vect-but-order.ll +++ b/llvm/test/Transforms/SLPVectorizer/X86/gather-node-same-as-vect-but-order.ll @@ -21,8 +21,7 @@ define void @foo(ptr %i7, i32 %0, i1 %tobool62.not) { ; CHECK-NEXT: [[TMP10:%.*]] = shufflevector <4 x float> [[TMP8]], <4 x float> [[TMP9]], <4 x i32> <i32 0, i32 4, i32 5, i32 poison> ; CHECK-NEXT: [[TMP11:%.*]] = insertelement <4 x float> [[TMP10]], float [[TMP7]], i32 3 ; CHECK-NEXT: [[TMP12:%.*]] = fcmp olt <4 x float> [[TMP11]], zeroinitializer -; CHECK-NEXT: [[TMP13:%.*]] = load <4 x float>, ptr poison, align 16 -; CHECK-NEXT: [[TMP14:%.*]] = fcmp olt <4 x float> [[TMP13]], zeroinitializer +; CHECK-NEXT: [[TMP14:%.*]] = fcmp olt <4 x float> [[TMP5]], zeroinitializer ; CHECK-NEXT: [[TMP15:%.*]] = select <4 x i1> [[TMP14]], <4 x float> [[TMP5]], <4 x float> zeroinitializer ; CHECK-NEXT: [[TMP16:%.*]] = select <4 x i1> [[TMP12]], <4 x float> zeroinitializer, <4 x float> [[TMP15]] ; CHECK-NEXT: store <4 x float> [[TMP16]], ptr [[RC21]], align 4 |