1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=ipsccp -S %s | FileCheck %s
4 define i8 @range_from_lshr(i8 %a) {
5 ; CHECK-LABEL: @range_from_lshr(
7 ; CHECK-NEXT: [[A_SHR:%.*]] = lshr i8 [[A:%.*]], 1
8 ; CHECK-NEXT: [[SUB_1:%.*]] = sub nsw i8 [[A_SHR]], 1
9 ; CHECK-NEXT: [[SUB_2:%.*]] = sub i8 [[A_SHR]], -128
10 ; CHECK-NEXT: [[SUB_3:%.*]] = sub i8 [[A_SHR]], -127
11 ; CHECK-NEXT: [[SUB_4:%.*]] = sub i8 [[A_SHR]], -1
12 ; CHECK-NEXT: [[RES_1:%.*]] = xor i8 [[SUB_1]], [[SUB_2]]
13 ; CHECK-NEXT: [[RES_2:%.*]] = xor i8 [[RES_1]], [[SUB_3]]
14 ; CHECK-NEXT: [[RES_3:%.*]] = xor i8 [[RES_2]], [[SUB_4]]
15 ; CHECK-NEXT: ret i8 [[RES_3]]
18 %a.shr = lshr i8 %a, 1
19 %sub.1 = sub i8 %a.shr, 1
20 %sub.2 = sub i8 %a.shr, 128
21 %sub.3 = sub i8 %a.shr, 129
22 %sub.4 = sub i8 %a.shr, -1
23 %res.1 = xor i8 %sub.1, %sub.2
24 %res.2 = xor i8 %res.1, %sub.3
25 %res.3 = xor i8 %res.2, %sub.4
30 define i8 @sub_zero(i8 %a) {
31 ; CHECK-LABEL: @sub_zero(
33 ; CHECK-NEXT: [[SUB_1:%.*]] = sub i8 0, [[A:%.*]]
34 ; CHECK-NEXT: [[SUB_2:%.*]] = sub nuw nsw i8 -1, [[A]]
35 ; CHECK-NEXT: [[SUB_3:%.*]] = sub i8 1, [[A]]
36 ; CHECK-NEXT: [[SUB_4:%.*]] = sub i8 [[A]], -1
37 ; CHECK-NEXT: [[RES_1:%.*]] = xor i8 [[SUB_1]], [[SUB_2]]
38 ; CHECK-NEXT: [[RES_2:%.*]] = xor i8 [[RES_1]], [[SUB_3]]
39 ; CHECK-NEXT: [[RES_3:%.*]] = xor i8 [[RES_2]], [[SUB_4]]
40 ; CHECK-NEXT: ret i8 [[RES_3]]
44 %sub.2 = sub i8 -1, %a
46 %sub.4 = sub i8 %a, -1
47 %res.1 = xor i8 %sub.1, %sub.2
48 %res.2 = xor i8 %res.1, %sub.3
49 %res.3 = xor i8 %res.2, %sub.4