[llvm] [CodeGen] Emit a more efficient magic number multiplication for exact udivs (PR #87161)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 22 13:56:50 PDT 2024
================
@@ -5197,12 +5249,8 @@ bool CombinerHelper::matchUDivByConst(MachineInstr &MI) {
return false;
}
- auto CheckEltValue = [&](const Constant *C) {
- if (auto *CI = dyn_cast_or_null<ConstantInt>(C))
- return !CI->isZero();
- return false;
- };
- return matchUnaryPredicate(MRI, RHS, CheckEltValue);
+ return matchUnaryPredicate(
+ MRI, RHS, [](const Constant *C) { return C && !C->isZeroValue(); });
----------------
topperc wrote:
Why using isZeroValue()? that's primarily intended for floating point since it allows -0.0. isNullValue is more correct here.
https://github.com/llvm/llvm-project/pull/87161
More information about the llvm-commits
mailing list