[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:28:26 PDT 2023
goldstein.w.n added a comment.
In D154678#4486204 <https://reviews.llvm.org/D154678#4486204>, @arsenm wrote:
> In D154678#4486199 <https://reviews.llvm.org/D154678#4486199>, @goldstein.w.n wrote:
>
>> 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)))
>
> Yes. It seems InstCombine already turns fdiv by constant power of 2 to fmul, but not the unknown-but-known-to-be-pow2 case here
In the constant case, RCP(Constant) is free, here we need 3-4 instructions. Is that really more canonical?
Would argument we might as well drop the `fmul` entirely and stick with the original transform (for `fdiv` only)
or just drop entirely and rely on the backend patch.
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