[PATCH] D67564: [IR] allow fast-math-flags on phi of FP values

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 13 10:40:53 PDT 2019


spatel created this revision.
spatel added reviewers: hfinkel, efriedma, cameron.mcinally, mcberg2017.
Herald added subscribers: hiraditya, mcrosier.
Herald added a project: LLVM.

The changes here are based on the corresponding diffs for allowing FMF on 'select':
D61917 <https://reviews.llvm.org/D61917>

As discussed there, we want to have fast-math-flags be a property of an FP value because the alternative (having them on things like fcmp) leads to logical inconsistency such as:
https://bugs.llvm.org/show_bug.cgi?id=38086

The earlier patch for select made almost no practical difference because most unoptimized conditional code begins life as a phi (based on what I see in clang). 
Similarly, I don't expect this patch to do much on its own either because SimplifyCFG promptly drops the flags when converting to select on a minimal example like:
https://bugs.llvm.org/show_bug.cgi?id=39535

But once we have this plumbing in place, we should be able to wire up the FMF propagation and start solving cases like that.

The change to RecurrenceDescriptor::AddReductionVar() is required to prevent a regression in a LoopVectorize test. We are intersecting the FMF of any FPMathOperator there, so if a phi is not properly annotated, new math instructions may not be either. Once we fix the propagation in SimplifyCFG, it may be safe to remove that hack.


https://reviews.llvm.org/D67564

Files:
  llvm/docs/LangRef.rst
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Operator.h
  llvm/lib/Analysis/IVDescriptors.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/test/Bitcode/compatibility.ll
  llvm/unittests/IR/InstructionsTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67564.220132.patch
Type: text/x-patch
Size: 9082 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190913/d2039f45/attachment.bin>


More information about the llvm-commits mailing list