[llvm] [InstCombine] Simplification for (-a * b) / (a * b). (PR #71768)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 14 05:39:08 PST 2023
================
@@ -1544,6 +1544,10 @@ Instruction *InstCombinerImpl::visitSDiv(BinaryOperator &I) {
}
}
+ // -(X * Y) / (X * Y) --> -1
+ if (isKnownNegation(Op0, Op1, true)) {
+ return replaceInstUsesWith(I, ConstantInt::getAllOnesValue(Ty));
+ };
return nullptr;
----------------
nikic wrote:
```suggestion
if (isKnownNegation(Op0, Op1, /*NeedNSW*/ true))
return replaceInstUsesWith(I, ConstantInt::getAllOnesValue(Ty));
return nullptr;
```
https://github.com/llvm/llvm-project/pull/71768
More information about the llvm-commits
mailing list