From 7f4ae5c84cfa0ab5454e3303427f1ee424c0ebcd Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 31 Dec 2009 08:32:22 +0000 Subject: [PATCH] merge some more tests in. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92353 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/Reassociate/basictest.ll | 28 ++++++++++++++++++++++ test/Transforms/Reassociate/mul-factor3.ll | 15 ------------ test/Transforms/Reassociate/mul-neg-add.ll | 10 -------- 3 files changed, 28 insertions(+), 25 deletions(-) delete mode 100644 test/Transforms/Reassociate/mul-factor3.ll delete mode 100644 test/Transforms/Reassociate/mul-neg-add.ll diff --git a/test/Transforms/Reassociate/basictest.ll b/test/Transforms/Reassociate/basictest.ll index 445aaaa7f57..c7d54af1e4b 100644 --- a/test/Transforms/Reassociate/basictest.ll +++ b/test/Transforms/Reassociate/basictest.ll @@ -105,3 +105,31 @@ define i32 @test6() { ; CHECK: @test6 ; CHECK: ret i32 0 } + +; This should be one add and two multiplies. +define i32 @test7(i32 %A, i32 %B, i32 %C) { + %aa = mul i32 %A, %A + %aab = mul i32 %aa, %B + %ac = mul i32 %A, %C + %aac = mul i32 %ac, %A + %r = add i32 %aab, %aac + ret i32 %r +; CHECK: @test7 +; CHECK-NEXT: add i32 %C, %B +; CHECK-NEXT: mul i32 +; CHECK-NEXT: mul i32 +; CHECK-NEXT: ret i32 +} + + +define i32 @test8(i32 %X, i32 %Y, i32 %Z) { + %A = sub i32 0, %X + %B = mul i32 %A, %Y + ; (-X)*Y + Z -> Z-X*Y + %C = add i32 %B, %Z + ret i32 %C +; CHECK: @test8 +; CHECK-NEXT: %A = mul i32 %Y, %X +; CHECK-NEXT: %C = sub i32 %Z, %A +; CHECK-NEXT: ret i32 %C +} diff --git a/test/Transforms/Reassociate/mul-factor3.ll b/test/Transforms/Reassociate/mul-factor3.ll deleted file mode 100644 index 4d0517618e0..00000000000 --- a/test/Transforms/Reassociate/mul-factor3.ll +++ /dev/null @@ -1,15 +0,0 @@ -; This should be one add and two multiplies. - -; RUN: opt < %s -reassociate -instcombine -S > %t -; RUN: grep mul %t | count 2 -; RUN: grep add %t | count 1 - -define i32 @test(i32 %A, i32 %B, i32 %C) { - %aa = mul i32 %A, %A ; [#uses=1] - %aab = mul i32 %aa, %B ; [#uses=1] - %ac = mul i32 %A, %C ; [#uses=1] - %aac = mul i32 %ac, %A ; [#uses=1] - %r = add i32 %aab, %aac ; [#uses=1] - ret i32 %r -} - diff --git a/test/Transforms/Reassociate/mul-neg-add.ll b/test/Transforms/Reassociate/mul-neg-add.ll deleted file mode 100644 index dd6ddd9b62e..00000000000 --- a/test/Transforms/Reassociate/mul-neg-add.ll +++ /dev/null @@ -1,10 +0,0 @@ -; RUN: opt < %s -reassociate -instcombine -S |\ -; RUN: not grep {sub i32 0} - -define i32 @test(i32 %X, i32 %Y, i32 %Z) { - %A = sub i32 0, %X ; [#uses=1] - %B = mul i32 %A, %Y ; [#uses=1] - ; (-X)*Y + Z -> Z-X*Y - %C = add i32 %B, %Z ; [#uses=1] - ret i32 %C -}