[InstCombine] update test to use FileCheck and auto-generate checks

llvm-svn: 284242
This commit is contained in:
Sanjay Patel 2016-10-14 15:30:31 +00:00
parent c6c5965a42
commit ad0757febb
1 changed files with 148 additions and 71 deletions

View File

@ -1,135 +1,212 @@
; This test makes sure that sub instructions are properly eliminated
; even with arbitrary precision integers.
;
; RUN: opt < %s -instcombine -S | \
; RUN: grep -v "sub i19 %Cok, %Bok" | grep -v "sub i25 0, %Aok" | not grep sub
; END.
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S | FileCheck %s
define i23 @test1(i23 %A) {
%B = sub i23 %A, %A ; <i23> [#uses=1]
ret i23 %B
; CHECK-LABEL: @test1(
; CHECK-NEXT: ret i23 0
;
%B = sub i23 %A, %A
ret i23 %B
}
define i47 @test2(i47 %A) {
%B = sub i47 %A, 0 ; <i47> [#uses=1]
ret i47 %B
; CHECK-LABEL: @test2(
; CHECK-NEXT: ret i47 %A
;
%B = sub i47 %A, 0
ret i47 %B
}
define i97 @test3(i97 %A) {
%B = sub i97 0, %A ; <i97> [#uses=1]
%C = sub i97 0, %B ; <i97> [#uses=1]
ret i97 %C
; CHECK-LABEL: @test3(
; CHECK-NEXT: ret i97 %A
;
%B = sub i97 0, %A
%C = sub i97 0, %B
ret i97 %C
}
define i108 @test4(i108 %A, i108 %x) {
%B = sub i108 0, %A ; <i108> [#uses=1]
%C = sub i108 %x, %B ; <i108> [#uses=1]
ret i108 %C
; CHECK-LABEL: @test4(
; CHECK-NEXT: [[C:%.*]] = add i108 %x, %A
; CHECK-NEXT: ret i108 [[C]]
;
%B = sub i108 0, %A
%C = sub i108 %x, %B
ret i108 %C
}
define i19 @test5(i19 %A, i19 %Bok, i19 %Cok) {
%D = sub i19 %Bok, %Cok ; <i19> [#uses=1]
%E = sub i19 %A, %D ; <i19> [#uses=1]
ret i19 %E
; CHECK-LABEL: @test5(
; CHECK-NEXT: [[D1:%.*]] = sub i19 %Cok, %Bok
; CHECK-NEXT: [[E:%.*]] = add i19 [[D1]], %A
; CHECK-NEXT: ret i19 [[E]]
;
%D = sub i19 %Bok, %Cok
%E = sub i19 %A, %D
ret i19 %E
}
define i57 @test6(i57 %A, i57 %B) {
%C = and i57 %A, %B ; <i57> [#uses=1]
%D = sub i57 %A, %C ; <i57> [#uses=1]
ret i57 %D
; CHECK-LABEL: @test6(
; CHECK-NEXT: [[B_NOT:%.*]] = xor i57 %B, -1
; CHECK-NEXT: [[D:%.*]] = and i57 %A, [[B_NOT]]
; CHECK-NEXT: ret i57 [[D]]
;
%C = and i57 %A, %B
%D = sub i57 %A, %C
ret i57 %D
}
define i77 @test7(i77 %A) {
%B = sub i77 -1, %A ; <i77> [#uses=1]
ret i77 %B
; CHECK-LABEL: @test7(
; CHECK-NEXT: [[B:%.*]] = xor i77 %A, -1
; CHECK-NEXT: ret i77 [[B]]
;
%B = sub i77 -1, %A
ret i77 %B
}
define i27 @test8(i27 %A) {
%B = mul i27 9, %A ; <i27> [#uses=1]
%C = sub i27 %B, %A ; <i27> [#uses=1]
ret i27 %C
; CHECK-LABEL: @test8(
; CHECK-NEXT: [[C:%.*]] = shl i27 %A, 3
; CHECK-NEXT: ret i27 [[C]]
;
%B = mul i27 9, %A
%C = sub i27 %B, %A
ret i27 %C
}
define i42 @test9(i42 %A) {
%B = mul i42 3, %A ; <i42> [#uses=1]
%C = sub i42 %A, %B ; <i42> [#uses=1]
ret i42 %C
; CHECK-LABEL: @test9(
; CHECK-NEXT: [[C:%.*]] = mul i42 %A, -2
; CHECK-NEXT: ret i42 [[C]]
;
%B = mul i42 3, %A
%C = sub i42 %A, %B
ret i42 %C
}
define i124 @test10(i124 %A, i124 %B) {
%C = sub i124 0, %A ; <i124> [#uses=1]
%D = sub i124 0, %B ; <i124> [#uses=1]
%E = mul i124 %C, %D ; <i124> [#uses=1]
ret i124 %E
; CHECK-LABEL: @test10(
; CHECK-NEXT: [[E:%.*]] = mul i124 %A, %B
; CHECK-NEXT: ret i124 [[E]]
;
%C = sub i124 0, %A
%D = sub i124 0, %B
%E = mul i124 %C, %D
ret i124 %E
}
define i55 @test10a(i55 %A) {
%C = sub i55 0, %A ; <i55> [#uses=1]
%E = mul i55 %C, 7 ; <i55> [#uses=1]
ret i55 %E
; CHECK-LABEL: @test10a(
; CHECK-NEXT: [[E:%.*]] = mul i55 %A, -7
; CHECK-NEXT: ret i55 [[E]]
;
%C = sub i55 0, %A
%E = mul i55 %C, 7
ret i55 %E
}
define i1 @test11(i9 %A, i9 %B) {
%C = sub i9 %A, %B ; <i9> [#uses=1]
%cD = icmp ne i9 %C, 0 ; <i1> [#uses=1]
ret i1 %cD
; CHECK-LABEL: @test11(
; CHECK-NEXT: [[CD:%.*]] = icmp ne i9 %A, %B
; CHECK-NEXT: ret i1 [[CD]]
;
%C = sub i9 %A, %B
%cD = icmp ne i9 %C, 0
ret i1 %cD
}
define i43 @test12(i43 %A) {
%B = ashr i43 %A, 42 ; <i43> [#uses=1]
%C = sub i43 0, %B ; <i43> [#uses=1]
ret i43 %C
; CHECK-LABEL: @test12(
; CHECK-NEXT: [[C:%.*]] = lshr i43 %A, 42
; CHECK-NEXT: ret i43 [[C]]
;
%B = ashr i43 %A, 42
%C = sub i43 0, %B
ret i43 %C
}
define i79 @test13(i79 %A) {
%B = lshr i79 %A, 78 ; <i79> [#uses=1]
%C = sub i79 0, %B ; <i79> [#uses=1]
ret i79 %C
; CHECK-LABEL: @test13(
; CHECK-NEXT: [[C:%.*]] = ashr i79 %A, 78
; CHECK-NEXT: ret i79 [[C]]
;
%B = lshr i79 %A, 78
%C = sub i79 0, %B
ret i79 %C
}
define i1024 @test14(i1024 %A) {
%B = lshr i1024 %A, 1023 ; <i1024> [#uses=1]
%C = bitcast i1024 %B to i1024 ; <i1024> [#uses=1]
%D = sub i1024 0, %C ; <i1024> [#uses=1]
ret i1024 %D
; CHECK-LABEL: @test14(
; CHECK-NEXT: [[D:%.*]] = ashr i1024 %A, 1023
; CHECK-NEXT: ret i1024 [[D]]
;
%B = lshr i1024 %A, 1023
%C = bitcast i1024 %B to i1024
%D = sub i1024 0, %C
ret i1024 %D
}
define i51 @test16(i51 %A) {
%X = sdiv i51 %A, 1123 ; <i51> [#uses=1]
%Y = sub i51 0, %X ; <i51> [#uses=1]
ret i51 %Y
; CHECK-LABEL: @test16(
; CHECK-NEXT: [[Y:%.*]] = sdiv i51 %A, -1123
; CHECK-NEXT: ret i51 [[Y]]
;
%X = sdiv i51 %A, 1123
%Y = sub i51 0, %X
ret i51 %Y
}
; Can't fold subtract here because negation it might oveflow.
; Can't fold subtract here because negation might overflow.
; PR3142
define i25 @test17(i25 %Aok) {
%B = sub i25 0, %Aok ; <i25> [#uses=1]
%C = sdiv i25 %B, 1234 ; <i25> [#uses=1]
ret i25 %C
; CHECK-LABEL: @test17(
; CHECK-NEXT: [[B:%.*]] = sub i25 0, %Aok
; CHECK-NEXT: [[C:%.*]] = sdiv i25 [[B]], 1234
; CHECK-NEXT: ret i25 [[C]]
;
%B = sub i25 0, %Aok
%C = sdiv i25 %B, 1234
ret i25 %C
}
define i128 @test18(i128 %Y) {
%tmp.4 = shl i128 %Y, 2 ; <i128> [#uses=1]
%tmp.12 = shl i128 %Y, 2 ; <i128> [#uses=1]
%tmp.8 = sub i128 %tmp.4, %tmp.12 ; <i128> [#uses=1]
ret i128 %tmp.8
; CHECK-LABEL: @test18(
; CHECK-NEXT: ret i128 0
;
%t1 = shl i128 %Y, 2
%t2 = shl i128 %Y, 2
%t3 = sub i128 %t1, %t2
ret i128 %t3
}
define i39 @test19(i39 %X, i39 %Y) {
%Z = sub i39 %X, %Y ; <i39> [#uses=1]
%Q = add i39 %Z, %Y ; <i39> [#uses=1]
ret i39 %Q
; CHECK-LABEL: @test19(
; CHECK-NEXT: ret i39 %X
;
%Z = sub i39 %X, %Y
%Q = add i39 %Z, %Y
ret i39 %Q
}
define i1 @test20(i33 %g, i33 %h) {
%tmp.2 = sub i33 %g, %h ; <i33> [#uses=1]
%tmp.4 = icmp ne i33 %tmp.2, %g ; <i1> [#uses=1]
ret i1 %tmp.4
; CHECK-LABEL: @test20(
; CHECK-NEXT: [[T4:%.*]] = icmp ne i33 %h, 0
; CHECK-NEXT: ret i1 [[T4]]
;
%t2 = sub i33 %g, %h
%t4 = icmp ne i33 %t2, %g
ret i1 %t4
}
define i1 @test21(i256 %g, i256 %h) {
%tmp.2 = sub i256 %g, %h ; <i256> [#uses=1]
%tmp.4 = icmp ne i256 %tmp.2, %g; <i1> [#uses=1]
ret i1 %tmp.4
; CHECK-LABEL: @test21(
; CHECK-NEXT: [[T4:%.*]] = icmp ne i256 %h, 0
; CHECK-NEXT: ret i1 [[T4]]
;
%t2 = sub i256 %g, %h
%t4 = icmp ne i256 %t2, %g
ret i1 %t4
}