[PATCH] D154805: [DAGCombiner] Fold IEEE `fmul`/`fdiv` by Pow2 to `add`/`sub` of exp

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 23 16:19:35 PDT 2023


arsenm added a comment.

In D154805#4611744 <https://reviews.llvm.org/D154805#4611744>, @goldstein.w.n wrote:

> why is that? ldexp gets lowered as mul/div and its not really possible to transform ldexp into this.

It doesn't lower to mul/div (and it may need a range check, at least for div). Most targets use the libcall

It's approximately

  fmul x, pow2_k => ldexp(x, log2(pow2_k)
  fmul x, pow2_k => ldexp(x, -log2(pow2_k)

with a possible additional precondition for the exponent range


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154805/new/

https://reviews.llvm.org/D154805



More information about the llvm-commits mailing list