[llvm-commits] Patch: Floating point optimizations for SimplifyInstruction

Michael Ilseman milseman at apple.com
Wed Dec 5 16:34:51 PST 2012


Here's a second round of patches, incorporating the review feedback Duncan had given me earlier but I had spaced. The biggest difference is an extension to PatternMatch.h for pattern matching ConstantFP values of interest.

Patch1: Pattern matching for more floating point values: -0, +/-0, 1.0, and ConstantFPs

Patch2: Added a slew of SimplifyInstruction floating-point optimizations, many of which take advantage of fast-math flags. Test cases included.
  fsub X, 0 ==> X
  fsub 0, (fsub 0, X) ==> X
  fsub X, -0 ==> X
    when X is known non-negative-zero, e.g. the fsub is nsz.
  fsub nnan ninf x, x ==> 0.0
  fadd X, -0 ==> X
  fadd X, 0 ==> X
    when X is known non-negative-zero, e.g. the fadd is nsz.
  fadd [nnan ninf] X, (fsub [nnan ninf] 0, X) ==> 0
    where nnan and ninf have to occur at least once somewhere in this expression
  fmul X, 1.0 ==> X



-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Pattern-matching-for-more-floating-point-values-0-0-.patch
Type: application/octet-stream
Size: 4333 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121205/570a3c4e/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Added-a-slew-of-SimplifyInstruction-floating-point-o.patch
Type: application/octet-stream
Size: 11451 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121205/570a3c4e/attachment-0001.obj>
-------------- next part --------------




On Dec 4, 2012, at 3:19 PM, Michael Ilseman <milseman at apple.com> wrote:

> Attached is a patch adding some floating-point optimizations to SimplifyInstruction, some of which take advantage of fast-math flags. Test cases included.
> 
> The optimizations themselves:
>  fsub X, 0 ==> X
> 
>  fsub 0, (fsub 0, X) ==> X
> 
>  fadd nsz X, 0 ==> X
> 
>  fadd [nnan ninf] X, (fsub [nnan ninf] 0, X) ==> 0
>    where nnan and ninf have to occur at least once somewhere in this expression
> 
>  fsub nnan ninf x, x ==> 0.0
> 
> <0001-Added-a-slew-of-SimplifyInstruction-floating-point-o.patch>



More information about the llvm-commits mailing list