merge some more tests in.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92353 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-12-31 08:32:22 +00:00
parent e1f5460f78
commit 7f4ae5c84c
3 changed files with 28 additions and 25 deletions

View File

@ -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
}

View File

@ -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 ; <i32> [#uses=1]
%aab = mul i32 %aa, %B ; <i32> [#uses=1]
%ac = mul i32 %A, %C ; <i32> [#uses=1]
%aac = mul i32 %ac, %A ; <i32> [#uses=1]
%r = add i32 %aab, %aac ; <i32> [#uses=1]
ret i32 %r
}

View File

@ -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 ; <i32> [#uses=1]
%B = mul i32 %A, %Y ; <i32> [#uses=1]
; (-X)*Y + Z -> Z-X*Y
%C = add i32 %B, %Z ; <i32> [#uses=1]
ret i32 %C
}