[PATCH] D26436: Fix for lost FastMathFlags in 4 optimizations.

Vyacheslav Klochkov via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 8 17:47:37 PST 2016


v_klochkov created this revision.
v_klochkov added subscribers: llvm-commits, majnemer, chandlerc, nadav, wolfgangp.
Herald added a subscriber: mzolotukhin.

Hello,

Please review the trivial fixes in 4 different optimizations 
that occasionally/wrongly lost FastMathFlags in FP operations.

I have more fixes for many cases in InstCombiner module,
but those are a bit more difficult and should be submitted for code-review separately.

Also, I added the developers, whose lines I changed, to the Subscribers list. (I used svn blame to get that list).

Thanks you,
Vyacheslav Klochkov

lib/Transforms/Scalar/GVN.cpp

  Before GVN:  
    t1 = <fast> a+b
    store t1 to [mem1]
    ...
    t2 = load [mem1]
    use t2
  After GVN:
    t1 = a+b // this operation must remain the <fast> flags!
    store t1 to [mem1]
    ...
    use t1 instead of original use of t2 (where t2=load from [mem1]).
  
  The uses of t2 were replaced by uses of t1.
  Unfortunately, both t1 and t2 can be cast to <FPMathOperator> 
  (the load could be cast as well because the resulf of load was FP),
  but here it is clear that math-flags of t1 and t2 should NOT be AND-ed.

lib/Transforms/Scalar/Reassociate.cpp

  Before:
    ((a*b)*c)*d // all MUL operations have <fast> math flags.
  After:
    (a*b)*(c*d) // all MUL operations lost <fast> math flags.

lib/Transforms/Vectorize/SLPVectorizer.cpp

  FastMath flags were not propagated to a newly created FCmp operation.

lib/CodeGen/CodeGenPrepare.cpp

  FastMath flags were not propagated to a newly created FCmp operation.


https://reviews.llvm.org/D26436

Files:
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/Transforms/Scalar/GVN.cpp
  llvm/lib/Transforms/Scalar/Reassociate.cpp
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26436.77294.patch
Type: text/x-patch
Size: 4040 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161109/e90809f8/attachment.bin>


More information about the llvm-commits mailing list