From 734b016b66c7bc1ef93b294c9bf7bbbd2c02a044 Mon Sep 17 00:00:00 2001 From: Douglas Yung Date: Fri, 20 Oct 2023 10:59:07 -0700 Subject: [PATCH] Revert "[SLP] Improve gather tree nodes matching when users are PHIs. (#69392)" This reverts commit c80b50349648dcf7fcbf4ae69c62b3d34bee0c70. This change causes a fatal error in the backend and is filed as issue #69670. --- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 8 +++----- .../SLPVectorizer/X86/matching-gather-nodes-phi-users.ll | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 1142d2112803..f694ab88ccab 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -9043,7 +9043,6 @@ BoUpSLP::isGatherShuffledEntry(const TreeEntry *TE, ArrayRef VL, // blocks. if (auto *PHI = dyn_cast(TEUseEI.UserTE->getMainOp())) { TEInsertBlock = PHI->getIncomingBlock(TEUseEI.EdgeIdx); - TEInsertPt = TEInsertBlock->getTerminator(); } else { TEInsertBlock = TEInsertPt->getParent(); } @@ -9107,10 +9106,9 @@ BoUpSLP::isGatherShuffledEntry(const TreeEntry *TE, ArrayRef VL, const Instruction *InsertPt = UserPHI ? UserPHI->getIncomingBlock(UseEI.EdgeIdx)->getTerminator() : &getLastInstructionInBundle(UseEI.UserTE); - if (TEInsertPt == InsertPt) { - // If 2 gathers are operands of the same entry (regardless of wether - // user is PHI or else), compare operands indices, use the earlier one - // as the base. + if (!UserPHI && TEInsertPt == InsertPt) { + // If 2 gathers are operands of the same non-PHI entry, + // compare operands indices, use the earlier one as the base. if (TEUseEI.UserTE == UseEI.UserTE && TEUseEI.EdgeIdx < UseEI.EdgeIdx) continue; // If the user instruction is used for some reason in different diff --git a/llvm/test/Transforms/SLPVectorizer/X86/matching-gather-nodes-phi-users.ll b/llvm/test/Transforms/SLPVectorizer/X86/matching-gather-nodes-phi-users.ll index e5d7ad138b4d..28e0b06f6967 100644 --- a/llvm/test/Transforms/SLPVectorizer/X86/matching-gather-nodes-phi-users.ll +++ b/llvm/test/Transforms/SLPVectorizer/X86/matching-gather-nodes-phi-users.ll @@ -8,7 +8,7 @@ ; YAML: Function: test ; YAML: Args: ; YAML: - String: 'Stores SLP vectorized with cost ' -; YAML: - Cost: '-6' +; YAML: - Cost: '-3' ; YAML: - String: ' and with tree size ' ; YAML: - TreeSize: '14' ; YAML: ...