[llvm] [InstCombine] Simplify select using KnownBits of condition (PR #95923)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 18 10:19:35 PDT 2024
================
@@ -4018,5 +4018,30 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
if (CondVal->getType() == SI.getType() && isKnownInversion(FalseVal, TrueVal))
return BinaryOperator::CreateXor(CondVal, FalseVal);
+ if (SelType->isIntOrIntVectorTy()) {
+ // Try to simplify select arms based on KnownBits implied by the condition.
+ CondContext CC(CondVal);
+ findValuesAffectedByCondition(CondVal, /*IsAssume=*/false, [&](Value *V) {
+ CC.AffectedValues.insert(V);
+ });
----------------
goldsteinn wrote:
Actually, think you really should only add `V` if its `TrueArm`/`FalseArm`.
https://github.com/llvm/llvm-project/pull/95923
More information about the llvm-commits
mailing list