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

Austin Kerbow via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 3 18:50:41 PST 2020


kerbowa added inline comments.


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp:737-740
+char AMDGPUTargetLowering::isNegatibleForFree(SDValue Op, SelectionDAG &DAG,
+                                              bool LegalOperations,
+                                              bool ForCodeSize,
+                                              unsigned Depth) const {
----------------
arsenm wrote:
> My initial thought is it should not be necessary to override this
I had the same initial thought.

The issue is that performFNegCombine is doing the right thing. And the generic fma combine show below relies on 'isNegatibleForFree'. In this case it's not actually profitable.

if (!TLI.isFNegFree(VT) &&
+      TLI.isNegatibleForFree(SDValue(N, 0), DAG, LegalOperations,
+                                              ForCodeSize) == 2)


================
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:
> 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.


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