1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
4 define i8 @urem_low_bits_know(i8 %xx, i8 %yy) {
5 ; CHECK-LABEL: @urem_low_bits_know(
15 define i8 @urem_high_bits_know(i8 %xx, i8 %yy) {
16 ; CHECK-LABEL: @urem_high_bits_know(
17 ; CHECK-NEXT: ret i8 0
26 define i8 @urem_low_bits_know2(i8 %xx, i8 %yy) {
27 ; CHECK-LABEL: @urem_low_bits_know2(
28 ; CHECK-NEXT: ret i8 2
38 define i8 @urem_todo_low_bits_partially_know_should_fold_out_urem(i8 %xx, i8 %yy) {
39 ; CHECK-LABEL: @urem_todo_low_bits_partially_know_should_fold_out_urem(
40 ; CHECK-NEXT: [[X:%.*]] = or i8 [[XX:%.*]], 2
41 ; CHECK-NEXT: [[Y:%.*]] = and i8 [[YY:%.*]], -4
42 ; CHECK-NEXT: [[REM:%.*]] = urem i8 [[X]], [[Y]]
43 ; CHECK-NEXT: [[R:%.*]] = and i8 [[REM]], 3
44 ; CHECK-NEXT: ret i8 [[R]]
53 define i8 @urem_fail_low_bits_unknown(i8 %xx, i8 %yy) {
54 ; CHECK-LABEL: @urem_fail_low_bits_unknown(
55 ; CHECK-NEXT: [[X:%.*]] = or i8 [[XX:%.*]], 4
56 ; CHECK-NEXT: [[Y:%.*]] = and i8 [[YY:%.*]], -4
57 ; CHECK-NEXT: [[REM:%.*]] = urem i8 [[X]], [[Y]]
58 ; CHECK-NEXT: [[R:%.*]] = and i8 [[REM]], 2
59 ; CHECK-NEXT: ret i8 [[R]]
68 define i8 @urem_fail_low_bits_unknown2(i8 %xx, i8 %yy) {
69 ; CHECK-LABEL: @urem_fail_low_bits_unknown2(
70 ; CHECK-NEXT: [[X:%.*]] = or i8 [[XX:%.*]], 1
71 ; CHECK-NEXT: [[Y:%.*]] = and i8 [[YY:%.*]], -5
72 ; CHECK-NEXT: [[REM:%.*]] = urem i8 [[X]], [[Y]]
73 ; CHECK-NEXT: [[R:%.*]] = and i8 [[REM]], 2
74 ; CHECK-NEXT: ret i8 [[R]]
83 define i8 @srem_low_bits_know(i8 %xx, i8 %yy) {
84 ; CHECK-LABEL: @srem_low_bits_know(
85 ; CHECK-NEXT: ret i8 2
94 define i8 @srem_low_bits_know2(i8 %xx, i8 %yy) {
95 ; CHECK-LABEL: @srem_low_bits_know2(
96 ; CHECK-NEXT: ret i8 1
100 %rem = srem i8 %x, %y
105 define i8 @srem_high_bits_know(i8 %xx, i8 %yy) {
106 ; CHECK-LABEL: @srem_high_bits_know(
107 ; CHECK-NEXT: ret i8 -2
111 %rem = srem i8 %x, %y
116 define i8 @srem_high_bits_know2(i8 %xx, i8 %yy) {
117 ; CHECK-LABEL: @srem_high_bits_know2(
118 ; CHECK-NEXT: ret i8 0
122 %rem = srem i8 %x, %y
127 define i8 @srem_high_bits_know3(i8 %xx, i8 %yy) {
128 ; CHECK-LABEL: @srem_high_bits_know3(
129 ; CHECK-NEXT: ret i8 8
133 %rem = srem i8 %x, %y
138 define i8 @srem_high_bits_know4(i8 %xx, i8 %yy) {
139 ; CHECK-LABEL: @srem_high_bits_know4(
140 ; CHECK-NEXT: ret i8 0
144 %rem = srem i8 %x, %y
149 define i8 @srem_high_bits_know5(i8 %xx, i8 %yy) {
150 ; CHECK-LABEL: @srem_high_bits_know5(
151 ; CHECK-NEXT: [[X:%.*]] = and i8 [[XX:%.*]], 2
152 ; CHECK-NEXT: ret i8 [[X]]
156 %rem = srem i8 %x, %y
161 define i8 @srem_todo_low_bits_partially_know_should_fold_out_srem(i8 %xx, i8 %yy) {
162 ; CHECK-LABEL: @srem_todo_low_bits_partially_know_should_fold_out_srem(
163 ; CHECK-NEXT: [[X:%.*]] = or i8 [[XX:%.*]], 10
164 ; CHECK-NEXT: [[Y:%.*]] = and i8 [[YY:%.*]], -4
165 ; CHECK-NEXT: [[REM:%.*]] = srem i8 [[X]], [[Y]]
166 ; CHECK-NEXT: [[R:%.*]] = and i8 [[REM]], 3
167 ; CHECK-NEXT: ret i8 [[R]]
171 %rem = srem i8 %x, %y
176 define i8 @srem_fail_low_bits_unknown(i8 %xx, i8 %yy) {
177 ; CHECK-LABEL: @srem_fail_low_bits_unknown(
178 ; CHECK-NEXT: [[X:%.*]] = or i8 [[XX:%.*]], 4
179 ; CHECK-NEXT: [[Y:%.*]] = and i8 [[YY:%.*]], -4
180 ; CHECK-NEXT: [[REM:%.*]] = srem i8 [[X]], [[Y]]
181 ; CHECK-NEXT: [[R:%.*]] = and i8 [[REM]], 2
182 ; CHECK-NEXT: ret i8 [[R]]
186 %rem = srem i8 %x, %y
191 define i8 @srem_fail_irrelivent_bits_known(i8 %xx, i8 %yy) {
192 ; CHECK-LABEL: @srem_fail_irrelivent_bits_known(
193 ; CHECK-NEXT: [[X:%.*]] = or i8 [[XX:%.*]], 3
194 ; CHECK-NEXT: [[Y:%.*]] = and i8 [[YY:%.*]], -6
195 ; CHECK-NEXT: [[REM:%.*]] = srem i8 [[X]], [[Y]]
196 ; CHECK-NEXT: [[R:%.*]] = and i8 [[REM]], 2
197 ; CHECK-NEXT: ret i8 [[R]]
201 %rem = srem i8 %x, %y