[llvm] [InstCombine] Simplify select using KnownBits of condition (PR #95923)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 19 02:54:12 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);
+ });
----------------
nikic wrote:
I didn't get what you refer to with "saving an iteration of InstCombine" -- how can we save an InstCombine iteration?
For the record, this is the impact of the KnownBits calculation (as opposed to the extra member and the affected value calculation): http://llvm-compile-time-tracker.com/compare.php?from=c9edd08d49137e47fe3acda3ea5b2bae563cb3ac&to=db730283063dff0dc72338413f346bd0174dafdd&stat=instructions:u
https://github.com/llvm/llvm-project/pull/95923
More information about the llvm-commits
mailing list