diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2022-03-25 15:11:49 +0300 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2022-03-25 16:12:17 +0300 |
commit | f6b60b3b79606612e9df6b3ab8d4367ca673fedc (patch) | |
tree | 41f0cbe217b396834f9049ae7db45eb5530c587c /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | ead294b74c4ba378f9eaf21f5f34bb42d93458ea (diff) | |
download | llvm-f6b60b3b79606612e9df6b3ab8d4367ca673fedc.zip llvm-f6b60b3b79606612e9df6b3ab8d4367ca673fedc.tar.gz llvm-f6b60b3b79606612e9df6b3ab8d4367ca673fedc.tar.bz2 |
[SimplifyCFG] `FoldBranchToCommonDest()`: allow branch-on-select
This whole check is bogus, it's some kind of a profitability check.
For now, simply extend it to not only allow branch-on-binary-ops,
but also on poison-safe logic ops.
Refs. https://github.com/llvm/llvm-project/issues/53861
Refs. https://github.com/llvm/llvm-project/issues/54553
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index d48c52d..29c5936 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -3531,7 +3531,9 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, DomTreeUpdater *DTU, Instruction *Cond = dyn_cast<Instruction>(BI->getCondition()); - if (!Cond || (!isa<CmpInst>(Cond) && !isa<BinaryOperator>(Cond)) || + if (!Cond || + (!isa<CmpInst>(Cond) && !isa<BinaryOperator>(Cond) && + !isa<SelectInst>(Cond)) || Cond->getParent() != BB || !Cond->hasOneUse()) return false; |