[Reassociate] Canonicalizing 'x [+-] (-Constant * y)' isn't always a win
authorDavid Majnemer <david.majnemer@gmail.com>
Thu, 28 May 2015 06:16:39 +0000 (06:16 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Thu, 28 May 2015 06:16:39 +0000 (06:16 +0000)
commit48e2671cb6eeb6dc9498d72e4586c21ae32f37ed
treed398387fdeb0b364874334571d307dd688ffe3d1
parent4977e92629c117182240a0cd7a56067fefed8574
[Reassociate] Canonicalizing 'x [+-] (-Constant * y)' isn't always a win

Canonicalizing 'x [+-] (-Constant * y)' is not a win if we don't *know*
we will open up CSE opportunities.

If the multiply was 'nsw', then negating 'y' requires us to clear the
'nsw' flag.  If this is actually worth pursuing, it is probably more
appropriate to do so in GVN or EarlyCSE.

This fixes PR23675.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238397 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/Reassociate.cpp
test/Transforms/Reassociate/basictest.ll
test/Transforms/Reassociate/canonicalize-neg-const.ll