Merge or combine tests and convert to FileCheck.

- Move tests only exercising instsimplify to instsimplify's apint-or.ll
- Actually test the CHECK lines in instsimplify's apint-or.ll
- Merge the remaining tests in apint-or1.ll and apint-or2.ll, use FileCheck

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247045 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer 2015-09-08 18:36:56 +00:00
parent 242f547927
commit 8f85748178
4 changed files with 110 additions and 92 deletions

View File

@ -0,0 +1,79 @@
; RUN: opt < %s -instcombine -S | FileCheck %s
; These tests are for Integer BitWidth <= 64 && BitWidth % 2 != 0.
define i23 @test1(i23 %A) {
;; A | ~A == -1
%NotA = xor i23 -1, %A
%B = or i23 %A, %NotA
ret i23 %B
; CHECK-LABEL: @test1
; CHECK-NEXT: ret i23 -1
}
define i39 @test2(i39 %V, i39 %M) {
;; If we have: ((V + N) & C1) | (V & C2)
;; .. and C2 = ~C1 and C2 is 0+1+ and (N & C2) == 0
;; replace with V+N.
%C1 = xor i39 274877906943, -1 ;; C2 = 274877906943
%N = and i39 %M, 274877906944
%A = add i39 %V, %N
%B = and i39 %A, %C1
%D = and i39 %V, 274877906943
%R = or i39 %B, %D
ret i39 %R
; CHECK-LABEL: @test2
; CHECK-NEXT: %N = and i39 %M, -274877906944
; CHECK-NEXT: %A = add i39 %N, %V
; CHECK-NEXT: ret i39 %A
}
define i43 @test3(i43 %A, i43 %B) {
;; (~A | ~B) == (~(A & B)) - De Morgan's Law
%NotA = xor i43 %A, -1
%NotB = xor i43 %B, -1
%C1 = or i43 %NotA, %NotB
ret i43 %C1
; CHECK-LABEL: @test3
; CHECK-NEXT: %C1.demorgan = and i43 %A, %B
; CHECK-NEXT: %C1 = xor i43 %C1.demorgan, -1
; CHECK-NEXT: ret i43 %C1
}
; These tests are for Integer BitWidth > 64 && BitWidth <= 1024.
define i1023 @test4(i1023 %A) {
;; A | ~A == -1
%NotA = xor i1023 -1, %A
%B = or i1023 %A, %NotA
ret i1023 %B
; CHECK-LABEL: @test4
; CHECK-NEXT: ret i1023 -1
}
define i399 @test5(i399 %V, i399 %M) {
;; If we have: ((V + N) & C1) | (V & C2)
;; .. and C2 = ~C1 and C2 is 0+1+ and (N & C2) == 0
;; replace with V+N.
%C1 = xor i399 274877906943, -1 ;; C2 = 274877906943
%N = and i399 %M, 18446742974197923840
%A = add i399 %V, %N
%B = and i399 %A, %C1
%D = and i399 %V, 274877906943
%R = or i399 %B, %D
ret i399 %R
; CHECK-LABEL: @test5
; CHECK-NEXT: %N = and i399 %M, 18446742974197923840
; CHECK-NEXT: %A = add i399 %N, %V
; CHECK-NEXT: ret i399 %A
}
define i129 @test6(i129 %A, i129 %B) {
;; (~A | ~B) == (~(A & B)) - De Morgan's Law
%NotA = xor i129 %A, -1
%NotB = xor i129 %B, -1
%C1 = or i129 %NotA, %NotB
ret i129 %C1
; CHECK-LABEL: @test6
; CHECK-NEXT: %C1.demorgan = and i129 %A, %B
; CHECK-NEXT: %C1 = xor i129 %C1.demorgan, -1
; CHECK-NEXT: ret i129 %C1
}

View File

@ -1,45 +0,0 @@
; This test makes sure that or instructions are properly eliminated.
; This test is for Integer BitWidth <= 64 && BitWidth % 2 != 0.
;
; RUN: opt < %s -instcombine -S | not grep " or "
define i7 @test0(i7 %X) {
%Y = or i7 %X, 0
ret i7 %Y
}
define i17 @test1(i17 %X) {
%Y = or i17 %X, -1
ret i17 %Y
}
define i23 @test2(i23 %A) {
;; A | ~A == -1
%NotA = xor i23 -1, %A
%B = or i23 %A, %NotA
ret i23 %B
}
define i39 @test3(i39 %V, i39 %M) {
;; If we have: ((V + N) & C1) | (V & C2)
;; .. and C2 = ~C1 and C2 is 0+1+ and (N & C2) == 0
;; replace with V+N.
%C1 = xor i39 274877906943, -1 ;; C2 = 274877906943
%N = and i39 %M, 274877906944
%A = add i39 %V, %N
%B = and i39 %A, %C1
%D = and i39 %V, 274877906943
%R = or i39 %B, %D
ret i39 %R
}
define i43 @demorgan(i43 %A, i43 %B) {
;; (~A | ~B) == (~(A & B)) - De Morgan's Law
%NotA = xor i43 %A, -1
%NotB = xor i43 %B, -1
%C1 = or i43 %NotA, %NotB
ret i43 %C1
}

View File

@ -1,44 +0,0 @@
; This test makes sure that or instructions are properly eliminated.
; This test is for Integer BitWidth > 64 && BitWidth <= 1024.
;
; RUN: opt < %s -instcombine -S | not grep " or "
define i777 @test0(i777 %X) {
%Y = or i777 %X, 0
ret i777 %Y
}
define i117 @test1(i117 %X) {
%Y = or i117 %X, -1
ret i117 %Y
}
define i1023 @test2(i1023 %A) {
;; A | ~A == -1
%NotA = xor i1023 -1, %A
%B = or i1023 %A, %NotA
ret i1023 %B
}
define i399 @test3(i399 %V, i399 %M) {
;; If we have: ((V + N) & C1) | (V & C2)
;; .. and C2 = ~C1 and C2 is 0+1+ and (N & C2) == 0
;; replace with V+N.
%C1 = xor i399 274877906943, -1 ;; C2 = 274877906943
%N = and i399 %M, 18446742974197923840
%A = add i399 %V, %N
%B = and i399 %A, %C1
%D = and i399 %V, 274877906943
%R = or i399 %B, %D
ret i399 %R
}
define i129 @demorgan(i129 %A, i129 %B) {
;; (~A | ~B) == (~(A & B)) - De Morgan's Law
%NotA = xor i129 %A, -1
%NotB = xor i129 %B, -1
%C1 = or i129 %NotA, %NotB
ret i129 %C1
}

View File

@ -1,4 +1,4 @@
; RUN: opt < %s -instsimplify -S | not grep or
; RUN: opt < %s -instsimplify -S | FileCheck %s
; Test the case where integer BitWidth <= 64 && BitWidth % 2 != 0.
define i39 @test1(i39 %V, i39 %M) {
@ -18,8 +18,22 @@ define i39 @test1(i39 %V, i39 %M) {
; CHECK-NEXT: ret
}
define i7 @test2(i7 %X) {
%Y = or i7 %X, 0
ret i7 %Y
; CHECK-LABEL: @test2
; CHECK-NEXT: ret i7 %X
}
define i17 @test3(i17 %X) {
%Y = or i17 %X, -1
ret i17 %Y
; CHECK-LABEL: @test3
; CHECK-NEXT: ret i17 -1
}
; Test the case where Integer BitWidth > 64 && BitWidth <= 1024.
define i399 @test2(i399 %V, i399 %M) {
define i399 @test4(i399 %V, i399 %M) {
;; If we have: ((V + N) & C1) | (V & C2)
;; .. and C2 = ~C1 and C2 is 0+1+ and (N & C2) == 0
;; replace with V+N.
@ -30,8 +44,22 @@ define i399 @test2(i399 %V, i399 %M) {
%D = and i399 %V, 274877906943
%R = or i399 %B, %D
ret i399 %R
; CHECK-LABEL: @test2
; CHECK-LABEL: @test4
; CHECK-NEXT: and {{.*}}, 18446742974197923840
; CHECK-NEXT: add
; CHECK-NEXT: ret
}
define i777 @test5(i777 %X) {
%Y = or i777 %X, 0
ret i777 %Y
; CHECK-LABEL: @test5
; CHECK-NEXT: ret i777 %X
}
define i117 @test6(i117 %X) {
%Y = or i117 %X, -1
ret i117 %Y
; CHECK-LABEL: @test6
; CHECK-NEXT: ret i117 -1
}