[PATCH] D154805: [DAGCombiner] 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 17 16:46:51 PDT 2023


goldstein.w.n added inline comments.


================
Comment at: llvm/include/llvm/CodeGen/TargetLowering.h:3971
+  //     -> (bitcast_to_FP (add (bitcast_to_INT C), Log2(Pow2) << mantissa))
+  // (fdiv C, (uitofp Pow2))
+  //     -> (bitcast_to_FP (sub (bitcast_to_INT C), Log2(Pow2) << mantissa))
----------------
arsenm wrote:
> goldstein.w.n wrote:
> > arsenm wrote:
> > > I think this should just use the fmul case, and turn the compatible fdivs to fmul 
> > I'm not sure I understand. We will need an `fdiv` no matter what, at the very least for the reciprocal of the pow2.
> I mean you can rewrite fdiv by power of 2 as fmul by 2 to the negative power
but `2 ^ -N` requires a division. I.e `1 / (2 ^ N)` so I don't see the benefit.


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