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

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 30 04:37:12 PDT 2023


RKSimon added a comment.

Have you looked at using the existing DAG::isKnownToBeAPowerOfTwo and DAGCombiner::BuildLogBase2 methods?



================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:16281
+// 3) The fmul/fdiv add/sub will not go outside of min/max exponent bounds.
+static SDValue combineFMulOrFDivWithIntPow2(DAGCombiner *DC,
+                                            const TargetLowering &TLI,
----------------
Why not make this a DAGCombiner method directly?


================
Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:25191
+      FPVT.getScalarSizeInBits() != IntVT.getScalarSizeInBits())
+    return false;
+
----------------
Add a TODO - as I'm sure we can be more aggressive here, vXi64 uittofp in particular on pre-AVX512 targets, but smaller integers are often worth it since we'd have to extend them any way for the int-to-fp conversion.


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