[llvm] [InstCombine] Simplify and/or by replacing operands with constants (PR #77231)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 22 06:22:47 PST 2024
================
@@ -2708,6 +2752,11 @@ Instruction *InstCombinerImpl::visitAnd(BinaryOperator &I) {
if (Instruction *Res = foldBitwiseLogicWithIntrinsics(I, Builder))
return Res;
+ if (Value *V = simplifyAndOrWithOpReplaced(Op0, Op1, /*IsAnd*/ true, *this))
+ return BinaryOperator::CreateAnd(Op1, V);
----------------
nikic wrote:
```suggestion
return BinaryOperator::CreateAnd(V, Op1);
```
No semantic difference, but I'd try to preserve operand order in cases where it's easy to do, like here.
https://github.com/llvm/llvm-project/pull/77231
More information about the llvm-commits
mailing list