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_low_bits_know2(i8 %xx, i8 %yy) {
16 ; CHECK-LABEL: @urem_low_bits_know2(
17 ; CHECK-NEXT: ret i8 2
27 define i8 @urem_todo_low_bits_partially_know_should_fold_out_urem(i8 %xx, i8 %yy) {
28 ; CHECK-LABEL: @urem_todo_low_bits_partially_know_should_fold_out_urem(
29 ; CHECK-NEXT: [[X:%.*]] = or i8 [[XX:%.*]], 2
30 ; CHECK-NEXT: [[Y:%.*]] = and i8 [[YY:%.*]], -4
31 ; CHECK-NEXT: [[REM:%.*]] = urem i8 [[X]], [[Y]]
32 ; CHECK-NEXT: [[R:%.*]] = and i8 [[REM]], 3
33 ; CHECK-NEXT: ret i8 [[R]]
42 define i8 @urem_fail_low_bits_unknown(i8 %xx, i8 %yy) {
43 ; CHECK-LABEL: @urem_fail_low_bits_unknown(
44 ; CHECK-NEXT: [[X:%.*]] = or i8 [[XX:%.*]], 4
45 ; CHECK-NEXT: [[Y:%.*]] = and i8 [[YY:%.*]], -4
46 ; CHECK-NEXT: [[REM:%.*]] = urem i8 [[X]], [[Y]]
47 ; CHECK-NEXT: [[R:%.*]] = and i8 [[REM]], 2
48 ; CHECK-NEXT: ret i8 [[R]]
57 define i8 @urem_fail_low_bits_unknown2(i8 %xx, i8 %yy) {
58 ; CHECK-LABEL: @urem_fail_low_bits_unknown2(
59 ; CHECK-NEXT: [[X:%.*]] = or i8 [[XX:%.*]], 1
60 ; CHECK-NEXT: [[Y:%.*]] = and i8 [[YY:%.*]], -5
61 ; CHECK-NEXT: [[REM:%.*]] = urem i8 [[X]], [[Y]]
62 ; CHECK-NEXT: [[R:%.*]] = and i8 [[REM]], 2
63 ; CHECK-NEXT: ret i8 [[R]]
72 define i8 @srem_low_bits_know(i8 %xx, i8 %yy) {
73 ; CHECK-LABEL: @srem_low_bits_know(
74 ; CHECK-NEXT: ret i8 2
83 define i8 @srem_low_bits_know2(i8 %xx, i8 %yy) {
84 ; CHECK-LABEL: @srem_low_bits_know2(
85 ; CHECK-NEXT: ret i8 1
94 define i8 @srem_todo_low_bits_partially_know_should_fold_out_srem(i8 %xx, i8 %yy) {
95 ; CHECK-LABEL: @srem_todo_low_bits_partially_know_should_fold_out_srem(
96 ; CHECK-NEXT: [[X:%.*]] = or i8 [[XX:%.*]], 10
97 ; CHECK-NEXT: [[Y:%.*]] = and i8 [[YY:%.*]], -4
98 ; CHECK-NEXT: [[REM:%.*]] = srem i8 [[X]], [[Y]]
99 ; CHECK-NEXT: [[R:%.*]] = and i8 [[REM]], 3
100 ; CHECK-NEXT: ret i8 [[R]]
104 %rem = srem i8 %x, %y
109 define i8 @srem_fail_low_bits_unknown(i8 %xx, i8 %yy) {
110 ; CHECK-LABEL: @srem_fail_low_bits_unknown(
111 ; CHECK-NEXT: [[X:%.*]] = or i8 [[XX:%.*]], 4
112 ; CHECK-NEXT: [[Y:%.*]] = and i8 [[YY:%.*]], -4
113 ; CHECK-NEXT: [[REM:%.*]] = srem i8 [[X]], [[Y]]
114 ; CHECK-NEXT: [[R:%.*]] = and i8 [[REM]], 2
115 ; CHECK-NEXT: ret i8 [[R]]
119 %rem = srem i8 %x, %y
124 define i8 @srem_fail_irrelivent_bits_known(i8 %xx, i8 %yy) {
125 ; CHECK-LABEL: @srem_fail_irrelivent_bits_known(
126 ; CHECK-NEXT: [[X:%.*]] = or i8 [[XX:%.*]], 3
127 ; CHECK-NEXT: [[Y:%.*]] = and i8 [[YY:%.*]], -6
128 ; CHECK-NEXT: [[REM:%.*]] = srem i8 [[X]], [[Y]]
129 ; CHECK-NEXT: [[R:%.*]] = and i8 [[REM]], 2
130 ; CHECK-NEXT: ret i8 [[R]]
134 %rem = srem i8 %x, %y