2016-10-14 23:30:31 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
|
|
; RUN: opt < %s -instcombine -S | FileCheck %s
|
2007-03-24 04:48:34 +08:00
|
|
|
|
|
|
|
define i23 @test1(i23 %A) {
|
2016-10-14 23:30:31 +08:00
|
|
|
; CHECK-LABEL: @test1(
|
|
|
|
; CHECK-NEXT: ret i23 0
|
|
|
|
;
|
|
|
|
%B = sub i23 %A, %A
|
|
|
|
ret i23 %B
|
2007-03-24 04:48:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i47 @test2(i47 %A) {
|
2016-10-14 23:30:31 +08:00
|
|
|
; CHECK-LABEL: @test2(
|
|
|
|
; CHECK-NEXT: ret i47 %A
|
|
|
|
;
|
|
|
|
%B = sub i47 %A, 0
|
|
|
|
ret i47 %B
|
2007-03-24 04:48:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i97 @test3(i97 %A) {
|
2016-10-14 23:30:31 +08:00
|
|
|
; CHECK-LABEL: @test3(
|
|
|
|
; CHECK-NEXT: ret i97 %A
|
|
|
|
;
|
|
|
|
%B = sub i97 0, %A
|
|
|
|
%C = sub i97 0, %B
|
|
|
|
ret i97 %C
|
2007-03-24 04:48:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i108 @test4(i108 %A, i108 %x) {
|
2016-10-14 23:30:31 +08:00
|
|
|
; 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
|
2007-03-24 04:48:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i19 @test5(i19 %A, i19 %Bok, i19 %Cok) {
|
2016-10-14 23:30:31 +08:00
|
|
|
; 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
|
2007-03-24 04:48:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i57 @test6(i57 %A, i57 %B) {
|
2016-10-14 23:30:31 +08:00
|
|
|
; CHECK-LABEL: @test6(
|
|
|
|
; CHECK-NEXT: [[B_NOT:%.*]] = xor i57 %B, -1
|
2017-02-04 05:43:34 +08:00
|
|
|
; CHECK-NEXT: [[D:%.*]] = and i57 [[B_NOT]], %A
|
2016-10-14 23:30:31 +08:00
|
|
|
; CHECK-NEXT: ret i57 [[D]]
|
|
|
|
;
|
|
|
|
%C = and i57 %A, %B
|
|
|
|
%D = sub i57 %A, %C
|
|
|
|
ret i57 %D
|
2007-03-24 04:48:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i77 @test7(i77 %A) {
|
2016-10-14 23:30:31 +08:00
|
|
|
; CHECK-LABEL: @test7(
|
|
|
|
; CHECK-NEXT: [[B:%.*]] = xor i77 %A, -1
|
|
|
|
; CHECK-NEXT: ret i77 [[B]]
|
|
|
|
;
|
|
|
|
%B = sub i77 -1, %A
|
|
|
|
ret i77 %B
|
2007-03-24 04:48:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i27 @test8(i27 %A) {
|
2016-10-14 23:30:31 +08:00
|
|
|
; 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
|
2007-03-24 04:48:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i42 @test9(i42 %A) {
|
2016-10-14 23:30:31 +08:00
|
|
|
; 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
|
2007-03-24 04:48:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @test11(i9 %A, i9 %B) {
|
2016-10-14 23:30:31 +08:00
|
|
|
; 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
|
2007-03-24 04:48:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i43 @test12(i43 %A) {
|
2016-10-14 23:30:31 +08:00
|
|
|
; 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
|
2007-03-24 04:48:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i79 @test13(i79 %A) {
|
2016-10-14 23:30:31 +08:00
|
|
|
; 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
|
2007-03-24 04:48:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1024 @test14(i1024 %A) {
|
2016-10-14 23:30:31 +08:00
|
|
|
; 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
|
2007-03-24 04:48:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i51 @test16(i51 %A) {
|
2016-10-14 23:30:31 +08:00
|
|
|
; 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
|
2007-03-24 04:48:34 +08:00
|
|
|
}
|
|
|
|
|
2016-10-14 23:30:31 +08:00
|
|
|
; Can't fold subtract here because negation might overflow.
|
2008-11-30 11:42:12 +08:00
|
|
|
; PR3142
|
|
|
|
define i25 @test17(i25 %Aok) {
|
2016-10-14 23:30:31 +08:00
|
|
|
; 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
|
2007-03-24 04:48:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i128 @test18(i128 %Y) {
|
2016-10-14 23:30:31 +08:00
|
|
|
; 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
|
2007-03-24 04:48:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i39 @test19(i39 %X, i39 %Y) {
|
2016-10-14 23:30:31 +08:00
|
|
|
; CHECK-LABEL: @test19(
|
|
|
|
; CHECK-NEXT: ret i39 %X
|
|
|
|
;
|
|
|
|
%Z = sub i39 %X, %Y
|
|
|
|
%Q = add i39 %Z, %Y
|
|
|
|
ret i39 %Q
|
2007-03-24 04:48:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @test20(i33 %g, i33 %h) {
|
2016-10-14 23:30:31 +08:00
|
|
|
; 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
|
2007-03-24 04:48:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @test21(i256 %g, i256 %h) {
|
2016-10-14 23:30:31 +08:00
|
|
|
; 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
|
2007-03-24 04:48:34 +08:00
|
|
|
}
|