diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2024-10-21 12:59:26 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2024-10-23 18:27:38 +0000 |
commit | 5deeebd8c6ca991269e72902a7a62cada57947f6 (patch) | |
tree | 567581f635111f967190e41bc826ea0834be587c /contrib/llvm-project/llvm/lib/Transforms/Vectorize/VectorCombine.cpp | |
parent | 6e516c87b6d779911edde7481d8aef165b837a03 (diff) | |
parent | e6b732792813cf49a23ba2f780c55f8d3279183e (diff) |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Transforms/Vectorize/VectorCombine.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Transforms/Vectorize/VectorCombine.cpp | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/contrib/llvm-project/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/contrib/llvm-project/llvm/lib/Transforms/Vectorize/VectorCombine.cpp index 444598520c98..679934d07e36 100644 --- a/contrib/llvm-project/llvm/lib/Transforms/Vectorize/VectorCombine.cpp +++ b/contrib/llvm-project/llvm/lib/Transforms/Vectorize/VectorCombine.cpp @@ -1900,33 +1900,35 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) { // We need each element to be the same type of value, and check that each // element has a single use. - if (all_of(drop_begin(Item), [Item](InstLane IL) { - Value *FrontV = Item.front().first->get(); - if (!IL.first) - return true; - Value *V = IL.first->get(); - if (auto *I = dyn_cast<Instruction>(V); I && !I->hasOneUse()) - return false; - if (V->getValueID() != FrontV->getValueID()) - return false; - if (auto *CI = dyn_cast<CmpInst>(V)) - if (CI->getPredicate() != cast<CmpInst>(FrontV)->getPredicate()) - return false; - if (auto *CI = dyn_cast<CastInst>(V)) - if (CI->getSrcTy() != cast<CastInst>(FrontV)->getSrcTy()) - return false; - if (auto *SI = dyn_cast<SelectInst>(V)) - if (!isa<VectorType>(SI->getOperand(0)->getType()) || - SI->getOperand(0)->getType() != - cast<SelectInst>(FrontV)->getOperand(0)->getType()) - return false; - if (isa<CallInst>(V) && !isa<IntrinsicInst>(V)) - return false; - auto *II = dyn_cast<IntrinsicInst>(V); - return !II || (isa<IntrinsicInst>(FrontV) && - II->getIntrinsicID() == - cast<IntrinsicInst>(FrontV)->getIntrinsicID()); - })) { + auto CheckLaneIsEquivalentToFirst = [Item](InstLane IL) { + Value *FrontV = Item.front().first->get(); + if (!IL.first) + return true; + Value *V = IL.first->get(); + if (auto *I = dyn_cast<Instruction>(V); I && !I->hasOneUse()) + return false; + if (V->getValueID() != FrontV->getValueID()) + return false; + if (auto *CI = dyn_cast<CmpInst>(V)) + if (CI->getPredicate() != cast<CmpInst>(FrontV)->getPredicate()) + return false; + if (auto *CI = dyn_cast<CastInst>(V)) + if (CI->getSrcTy() != cast<CastInst>(FrontV)->getSrcTy()) + return false; + if (auto *SI = dyn_cast<SelectInst>(V)) + if (!isa<VectorType>(SI->getOperand(0)->getType()) || + SI->getOperand(0)->getType() != + cast<SelectInst>(FrontV)->getOperand(0)->getType()) + return false; + if (isa<CallInst>(V) && !isa<IntrinsicInst>(V)) + return false; + auto *II = dyn_cast<IntrinsicInst>(V); + return !II || (isa<IntrinsicInst>(FrontV) && + II->getIntrinsicID() == + cast<IntrinsicInst>(FrontV)->getIntrinsicID() && + !II->hasOperandBundles()); + }; + if (all_of(drop_begin(Item), CheckLaneIsEquivalentToFirst)) { // Check the operator is one that we support. if (isa<BinaryOperator, CmpInst>(FrontU)) { // We exclude div/rem in case they hit UB from poison lanes. @@ -1954,7 +1956,8 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) { Worklist.push_back(generateInstLaneVectorFromOperand(Item, 2)); continue; } else if (auto *II = dyn_cast<IntrinsicInst>(FrontU); - II && isTriviallyVectorizable(II->getIntrinsicID())) { + II && isTriviallyVectorizable(II->getIntrinsicID()) && + !II->hasOperandBundles()) { for (unsigned Op = 0, E = II->getNumOperands() - 1; Op < E; Op++) { if (isVectorIntrinsicWithScalarOpAtArg(II->getIntrinsicID(), Op)) { if (!all_of(drop_begin(Item), [Item, Op](InstLane &IL) { |