[llvm] [InstCombine] Simplify select using KnownBits of condition (PR #95923)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 28 09:29:34 PDT 2024
================
@@ -4018,5 +4045,32 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
if (CondVal->getType() == SI.getType() && isKnownInversion(FalseVal, TrueVal))
return BinaryOperator::CreateXor(CondVal, FalseVal);
+ if (SelType->isIntOrIntVectorTy()) {
----------------
dtcxzyw wrote:
```suggestion
if (SelType->isIntOrIntVectorTy() && (!isa<Constant>(TrueVal) || !isa<Constant>(FalseVal))) {
```
We can early exit if both of select arms are constants.
https://github.com/llvm/llvm-project/pull/95923
More information about the llvm-commits
mailing list