[Reassociate] try harder to convert negative FP constants to positive
authorSanjay Patel <spatel@rotateright.com>
Sat, 10 Aug 2019 13:17:54 +0000 (13:17 +0000)
committerSanjay Patel <spatel@rotateright.com>
Sat, 10 Aug 2019 13:17:54 +0000 (13:17 +0000)
commit21c15ef38487ee91eea898dbe80bfc5f8d6c5252
tree7c3943c233a67707e0ffb6ee834bd9a7b1676168
parentb448d1bf212219febbb182d00c210bad1bd25e7f
[Reassociate] try harder to convert negative FP constants to positive

This is an extension of a transform that tries to produce positive floating-point
constants to improve canonicalization (and hopefully lead to more reassociation
and CSE).

The original patches were:
D4904
D5363 (rL221721)

But as the test diffs show, these were limited to basic patterns by walking from
an instruction to its single user rather than recursively moving up the def-use
sequence. No fast-math is required here because we're only rearranging implicit
FP negations in intermediate ops.

A motivating bug is:
https://bugs.llvm.org/show_bug.cgi?id=32939

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

llvm-svn: 368512
llvm/include/llvm/Transforms/Scalar/Reassociate.h
llvm/lib/Transforms/Scalar/Reassociate.cpp
llvm/test/Transforms/Reassociate/canonicalize-neg-const.ll
llvm/test/Transforms/Reassociate/fast-ReassociateVector.ll
llvm/test/Transforms/Reassociate/reassoc-intermediate-fnegs.ll