[llvm] [BDCE] Handle multi-use `select` of `and`s on demanded bits (PR #79688)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 27 10:33:36 PST 2024
================
@@ -125,6 +125,33 @@ static bool bitTrackingDCE(Function &F, DemandedBits &DB) {
}
}
+ // Simplify select of ands when the mask does not affect the demanded bits.
+ if (SelectInst *SI = dyn_cast<SelectInst>(&I)) {
+ APInt Demanded = DB.getDemandedBits(SI);
+ if (!Demanded.isAllOnes()) {
+ for (Use &U : I.operands()) {
+ auto *And = dyn_cast<BinaryOperator>(&U);
+ if (!And || !And->hasOneUse() || And->getOpcode() != Instruction::And)
----------------
antoniofrighetto wrote:
Sure, thanks, adding it too.
https://github.com/llvm/llvm-project/pull/79688
More information about the llvm-commits
mailing list