[PATCH] D28507: [TM] Restore default TargetOptions in TargetMachine::resetTargetOptions.

Justin Lebar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 9 19:30:22 PST 2017


jlebar created this revision.
jlebar added a reviewer: mkuper.
jlebar added subscribers: llvm-commits, majnemer, hfinkel.
Herald added subscribers: nemanjai, jholewinski.

Previously if you had

- a function with the fast-math-enabled attr, followed by
- a function without the fast-math attr,

the second function would inherit the first function's fast-math-ness.

This means that mixing fast-math and non-fast-math functions in a module
was completely broken unless you explicitly annotated every
non-fast-math function with "unsafe-fp-math"="false".  This appears to
have been broken since at r176986 (March 2013), when the
resetTargetOptions function was introduced.

This patch tests the correct behavior as best we can.  I don't think I
can test FPDenormalMode and NoTrappingFPMath, because they aren't used
in any backends during function lowering.  Surprisingly, I also can't
find any uses at all of LessPreciseFPMAD affecting generated code.

The NVPTX/fast-math.ll test changes are an expected result of fixing
this bug.  When FMA is disabled, we emit add as "add.rn.f32", which
prevents fma combining.  Before this patch, we were emitting plain
"add.f32" in the two functions that came after the one where fast-math
was enabled.


https://reviews.llvm.org/D28507

Files:
  llvm/include/llvm/Target/TargetMachine.h
  llvm/lib/Target/TargetMachine.cpp
  llvm/test/CodeGen/NVPTX/fast-math.ll
  llvm/test/CodeGen/PowerPC/change-no-infs.ll
  llvm/test/CodeGen/X86/change-unsafe-fp-math.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28507.83768.patch
Type: text/x-patch
Size: 7141 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170110/8a6bc25c/attachment.bin>


More information about the llvm-commits mailing list