[PATCH] D154678: [InstCombine] Fold IEEE `fmul`/`fdiv` by Pow2 to `add`/`sub` of exp
Noah Goldstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 10 11:24:46 PDT 2023
goldstein.w.n added a comment.
In D154678#4486086 <https://reviews.llvm.org/D154678#4486086>, @arsenm wrote:
> In D154678#4481841 <https://reviews.llvm.org/D154678#4481841>, @goldstein.w.n wrote:
>
>>> Can we unconditionally turn fdiv into fmul if the divisor is known to be an exact power of 2?
>>
>> Not sure, best I can come up with just take reciprical.
>
> Seems to work for power of 2 known <= max_exp. Much better to do that rather than try to handle both
So you mean handle `fdiv` only and do the following:
(fdiv C, (uitofp Pow2))
-> (fmul C, (bitcast_to_FP (sub (FP_One), Log2(Pow2) << mantissa)))
?
Otherwise we still have the division to create the RCP. In this case
Seems we might as well also drop the `fmul`.
But I'm planning to abandon this patch as have implemented in the backend.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154678/new/
https://reviews.llvm.org/D154678
More information about the llvm-commits
mailing list