[llvm] [InstCombine] Simplify select using KnownBits of condition (PR #95923)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 19 04:40:55 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:
> I didn't get what you refer to with "saving an iteration of InstCombine" -- how can we save an InstCombine iteration?
>
I mean do the full transform in a single shot as opposed to going through the work list twice.
Iteration was wrong word to us there given it's other meaning.
https://github.com/llvm/llvm-project/pull/95923
More information about the llvm-commits
mailing list