reuse negates where possible instead of always creating them from scratch.
authorChris Lattner <sabre@nondot.org>
Thu, 31 Dec 2009 20:34:32 +0000 (20:34 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 31 Dec 2009 20:34:32 +0000 (20:34 +0000)
commit35239934517c6fcd52e3e965f40e03f74aa4d11d
treebf58090be7395d7c0708f44b0ac396210f9e167e
parentf31e2e92a801c5053dc9b3b484cdec73ad89e567
reuse negates where possible instead of always creating them from scratch.
This allows us to optimize test12 into:

define i32 @test12(i32 %X) {
  %factor = mul i32 %X, -3                        ; <i32> [#uses=1]
  %Z = add i32 %factor, 6                         ; <i32> [#uses=1]
  ret i32 %Z
}

instead of:

define i32 @test12(i32 %X) {
  %Y = sub i32 6, %X                              ; <i32> [#uses=1]
  %C = sub i32 %Y, %X                             ; <i32> [#uses=1]
  %Z = sub i32 %C, %X                             ; <i32> [#uses=1]
  ret i32 %Z
}

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