1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
6 define i8 @sub_not(i8 %x, i8 %y) {
7 ; CHECK-LABEL: @sub_not(
8 ; CHECK-NEXT: [[TMP1:%.*]] = xor i8 [[X:%.*]], -1
9 ; CHECK-NEXT: [[R:%.*]] = add i8 [[TMP1]], [[Y:%.*]]
10 ; CHECK-NEXT: ret i8 [[R]]
17 define i8 @sub_not_extra_use(i8 %x, i8 %y) {
18 ; CHECK-LABEL: @sub_not_extra_use(
19 ; CHECK-NEXT: [[S:%.*]] = sub i8 [[X:%.*]], [[Y:%.*]]
20 ; CHECK-NEXT: [[R:%.*]] = xor i8 [[S]], -1
21 ; CHECK-NEXT: call void @use(i8 [[S]])
22 ; CHECK-NEXT: ret i8 [[R]]
30 define <2 x i8> @sub_not_vec(<2 x i8> %x, <2 x i8> %y) {
31 ; CHECK-LABEL: @sub_not_vec(
32 ; CHECK-NEXT: [[TMP1:%.*]] = xor <2 x i8> [[X:%.*]], <i8 -1, i8 -1>
33 ; CHECK-NEXT: [[R:%.*]] = add <2 x i8> [[TMP1]], [[Y:%.*]]
34 ; CHECK-NEXT: ret <2 x i8> [[R]]
36 %s = sub <2 x i8> %x, %y
37 %r = xor <2 x i8> %s, <i8 -1, i8 undef>
41 define i8 @dec_sub(i8 %x, i8 %y) {
42 ; CHECK-LABEL: @dec_sub(
43 ; CHECK-NEXT: [[TMP1:%.*]] = xor i8 [[Y:%.*]], -1
44 ; CHECK-NEXT: [[R:%.*]] = add i8 [[TMP1]], [[X:%.*]]
45 ; CHECK-NEXT: ret i8 [[R]]
52 define i8 @dec_sub_extra_use(i8 %x, i8 %y) {
53 ; CHECK-LABEL: @dec_sub_extra_use(
54 ; CHECK-NEXT: [[S:%.*]] = sub i8 [[X:%.*]], [[Y:%.*]]
55 ; CHECK-NEXT: [[R:%.*]] = add i8 [[S]], -1
56 ; CHECK-NEXT: call void @use(i8 [[S]])
57 ; CHECK-NEXT: ret i8 [[R]]
65 define <2 x i8> @dec_sub_vec(<2 x i8> %x, <2 x i8> %y) {
66 ; CHECK-LABEL: @dec_sub_vec(
67 ; CHECK-NEXT: [[TMP1:%.*]] = xor <2 x i8> [[Y:%.*]], <i8 -1, i8 -1>
68 ; CHECK-NEXT: [[R:%.*]] = add <2 x i8> [[TMP1]], [[X:%.*]]
69 ; CHECK-NEXT: ret <2 x i8> [[R]]
71 %s = sub <2 x i8> %x, %y
72 %r = add <2 x i8> %s, <i8 -1, i8 undef>
76 define i8 @sub_inc(i8 %x, i8 %y) {
77 ; CHECK-LABEL: @sub_inc(
78 ; CHECK-NEXT: [[S_NEG:%.*]] = xor i8 [[X:%.*]], -1
79 ; CHECK-NEXT: [[R:%.*]] = add i8 [[S_NEG]], [[Y:%.*]]
80 ; CHECK-NEXT: ret i8 [[R]]
87 define i8 @sub_inc_extra_use(i8 %x, i8 %y) {
88 ; CHECK-LABEL: @sub_inc_extra_use(
89 ; CHECK-NEXT: [[S:%.*]] = add i8 [[X:%.*]], 1
90 ; CHECK-NEXT: [[R:%.*]] = sub i8 [[Y:%.*]], [[S]]
91 ; CHECK-NEXT: call void @use(i8 [[S]])
92 ; CHECK-NEXT: ret i8 [[R]]
100 define <2 x i8> @sub_inc_vec(<2 x i8> %x, <2 x i8> %y) {
101 ; CHECK-LABEL: @sub_inc_vec(
102 ; CHECK-NEXT: [[S_NEG:%.*]] = xor <2 x i8> [[X:%.*]], <i8 -1, i8 -1>
103 ; CHECK-NEXT: [[R:%.*]] = add <2 x i8> [[S_NEG]], [[Y:%.*]]
104 ; CHECK-NEXT: ret <2 x i8> [[R]]
106 %s = add <2 x i8> %x, <i8 undef, i8 1>
107 %r = sub <2 x i8> %y, %s
111 define i8 @sub_dec(i8 %x, i8 %y) {
112 ; CHECK-LABEL: @sub_dec(
113 ; CHECK-NEXT: [[TMP1:%.*]] = xor i8 [[Y:%.*]], -1
114 ; CHECK-NEXT: [[R:%.*]] = add i8 [[TMP1]], [[X:%.*]]
115 ; CHECK-NEXT: ret i8 [[R]]
122 define i8 @sub_dec_extra_use(i8 %x, i8 %y) {
123 ; CHECK-LABEL: @sub_dec_extra_use(
124 ; CHECK-NEXT: [[S:%.*]] = add i8 [[X:%.*]], -1
125 ; CHECK-NEXT: [[R:%.*]] = sub i8 [[S]], [[Y:%.*]]
126 ; CHECK-NEXT: call void @use(i8 [[S]])
127 ; CHECK-NEXT: ret i8 [[R]]
131 call void @use(i8 %s)
135 define <2 x i8> @sub_dec_vec(<2 x i8> %x, <2 x i8> %y) {
136 ; CHECK-LABEL: @sub_dec_vec(
137 ; CHECK-NEXT: [[TMP1:%.*]] = xor <2 x i8> [[Y:%.*]], <i8 -1, i8 -1>
138 ; CHECK-NEXT: [[R:%.*]] = add <2 x i8> [[TMP1]], [[X:%.*]]
139 ; CHECK-NEXT: ret <2 x i8> [[R]]
141 %s = add <2 x i8> %x, <i8 undef, i8 -1>
142 %r = sub <2 x i8> %s, %y