diff options
author | Phoebe Wang <phoebe.wang@intel.com> | 2024-09-16 20:20:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-16 20:20:36 +0800 |
commit | af5a45b34bcc84e175d54226d5898ae20fc3859c (patch) | |
tree | b0cdc86b4a05d6e1091e72d963ffc7040e4152a1 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | 87d56c59f52d033cd7c46d769338b9c47fea4929 (diff) | |
download | llvm-af5a45b34bcc84e175d54226d5898ae20fc3859c.zip llvm-af5a45b34bcc84e175d54226d5898ae20fc3859c.tar.gz llvm-af5a45b34bcc84e175d54226d5898ae20fc3859c.tar.bz2 |
[X86,SimplifyCFG] Use passthru to reduce select (#108754)
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index f9db996..5a694b5 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -3040,7 +3040,7 @@ static bool isSafeCheapLoadStore(const Instruction *I, /// %sub = sub %x, %y /// br label BB2 /// EndBB: -/// %phi = phi [ %sub, %ThenBB ], [ 0, %EndBB ] +/// %phi = phi [ %sub, %ThenBB ], [ 0, %BB ] /// ... /// \endcode /// @@ -3338,9 +3338,20 @@ bool SimplifyCFGOpt::speculativelyExecuteBB(BranchInst *BI, if (auto *LI = dyn_cast<LoadInst>(I)) { // Handle Load. auto *Ty = I->getType(); - MaskedLoadStore = Builder.CreateMaskedLoad(FixedVectorType::get(Ty, 1), - Op0, LI->getAlign(), Mask); - I->replaceAllUsesWith(Builder.CreateBitCast(MaskedLoadStore, Ty)); + PHINode *PN = nullptr; + Value *PassThru = nullptr; + for (User *U : I->users()) + if ((PN = dyn_cast<PHINode>(U))) { + PassThru = Builder.CreateBitCast(PN->getIncomingValueForBlock(BB), + FixedVectorType::get(Ty, 1)); + break; + } + MaskedLoadStore = Builder.CreateMaskedLoad( + FixedVectorType::get(Ty, 1), Op0, LI->getAlign(), Mask, PassThru); + Value *NewLoadStore = Builder.CreateBitCast(MaskedLoadStore, Ty); + if (PN) + PN->setIncomingValue(PN->getBasicBlockIndex(BB), NewLoadStore); + I->replaceAllUsesWith(NewLoadStore); } else { // Handle Store. auto *StoredVal = |