[all-commits] [llvm/llvm-project] 50afa1: [x86] split FMA with fast-math-flags to avoid libcall

RotateRight via All-commits all-commits at lists.llvm.org
Sun Jul 19 07:07:50 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 50afa18772daca0b6de253a7c5311c81b0a46682
      https://github.com/llvm/llvm-project/commit/50afa18772daca0b6de253a7c5311c81b0a46682
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2020-07-19 (Sun, 19 Jul 2020)

  Changed paths:
    M llvm/lib/Target/X86/X86ISelLowering.cpp
    M llvm/test/CodeGen/X86/fma.ll

  Log Message:
  -----------
  [x86] split FMA with fast-math-flags to avoid libcall

fma reassoc A, B, C --> fadd (fmul A, B), C (when target has no FMA hardware)

C/C++ code may use explicit fma() calls (which become LLVM fma
intrinsics in IR) but then gets compiled with -ffast-math or similar.
For targets that do not have FMA hardware, we don't want to go out to
the math library for a precise but slow FMA result.

I tried this as a generic DAGCombine, but it caused infinite looping
on more than 1 other target, so there's likely some over-reaching fma
formation happening.

There's also a potential intersection of strict FP with fast-math here.
Deferring to current behavior for that case (assuming that strict-ness
overrides fast-ness).

Differential Revision: https://reviews.llvm.org/D83981




More information about the All-commits mailing list