[PATCH] D31169: [DAGCombiner] Initial support for the fast-math flag contract

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 30 07:34:42 PDT 2017


spatel added reviewers: nhaehnle, jingyue.
spatel added a comment.

See inline for one more possible test case. I have no other comments, but I'm cc'ing some people who have worked on this function recently for potential feedback.



================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:8753-8756
+  if (Aggressive && isContractableFMUL(N0) && isContractableFMUL(N1)) {
     if (N0.getNode()->use_size() > N1.getNode()->use_size())
       std::swap(N0, N1);
   }
----------------
I think this diff exposes a possibility that didn't exist before, so it's worth adding a test for it:

  define float @cannot_choose_fma(float %f1, float %f2, float %f3, float %f4) {
    %mul1 = fmul contract float %f1, %f2
    %mul2 = fmul float %f3, %f4
    %add = fadd contract float %mul1, %mul2
    %second_use_of_mul1 = fdiv float %mul1, %add
    ret float %second_use_of_mul1
  }

  $ ./llc -o - fma.ll -mtriple=powerpc64-darwin 
    fmuls f0, f3, f4
    fmuls f13, f1, f2
    fmadds f0, f1, f2, f0
    fdivs f1, f13, f0



https://reviews.llvm.org/D31169





More information about the llvm-commits mailing list