[PATCH] D73939: [AMDGPU] Fix infinite loop with fma combines

Austin Kerbow via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 4 11:08:08 PST 2020


kerbowa added inline comments.


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp:742
+  switch (Op.getOpcode()) {
+    case ISD::FMA: {
+      // Negating a fma is not free if it has users without source mods.
----------------
arsenm wrote:
> kerbowa wrote:
> > arsenm wrote:
> > > This is incomplete and FMAD will have the same problem at minimum
> > The hang at least doesn't effect FMAD. The combine that triggers this wont happen.
> Where is the combine? It's also suspicious if an fneg combine triggered for FMA but not FMAD. 
It's a loop so there are combines in two directions.

The FNeg combine -fma(a, b, c) => fma(a, -b, -c), triggers for FMA/FMAD and is correct.

AFAICS the unprofitable combine, fma(a, -b, -c) => -fma(a, b, c), only triggers for FMA.
https://github.com/llvm/llvm-project/blob/master/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp#L12652


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73939





More information about the llvm-commits mailing list