[llvm] [CodeGen] Emit a more efficient magic number multiplication for exact udivs (PR #87161)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 13 07:40:53 PDT 2024
================
@@ -6141,6 +6138,68 @@ static SDValue BuildExactSDIV(const TargetLowering &TLI, SDNode *N,
return DAG.getNode(ISD::MUL, dl, VT, Res, Factor);
}
+/// Given an exact UDIV by a constant, create a multiplication
+/// with the multiplicative inverse of the constant.
----------------
AtariDreams wrote:
> Is there a reference for what this is doing somewhere?
> Is there a reference for what this is doing somewhere?
yes. hacker's delight, but this matches exactly what SDiv does too, since the algorithm is the same.
https://github.com/llvm/llvm-project/pull/87161
More information about the llvm-commits
mailing list