1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=instsimplify -S < %s | FileCheck %s
4 define i1 @test(i8 %p, ptr %pq) {
6 ; CHECK-NEXT: ret i1 false
8 %q = load i8, ptr %pq, !range !0 ; %q is known nonzero; no known bits
9 %1 = or i8 %p, 2 ; %1[1] = 1
10 %2 = and i8 %1, 254 ; %2[0] = 0, %2[1] = 1
11 %A = lshr i8 %2, 1 ; We should know that %A is nonzero.
18 ; The following cases only get folded by InstCombine,
19 ; see InstCombine/shift-shift.ll. If we wanted to,
20 ; we could explicitly handle them in InstSimplify as well.
22 define i32 @shl_shl(i32 %A) {
23 ; CHECK-LABEL: @shl_shl(
24 ; CHECK-NEXT: [[B:%.*]] = shl i32 [[A:%.*]], 6
25 ; CHECK-NEXT: [[C:%.*]] = shl i32 [[B]], 28
26 ; CHECK-NEXT: ret i32 [[C]]
33 define <2 x i33> @shl_shl_splat_vec(<2 x i33> %A) {
34 ; CHECK-LABEL: @shl_shl_splat_vec(
35 ; CHECK-NEXT: [[B:%.*]] = shl <2 x i33> [[A:%.*]], <i33 5, i33 5>
36 ; CHECK-NEXT: [[C:%.*]] = shl <2 x i33> [[B]], <i33 28, i33 28>
37 ; CHECK-NEXT: ret <2 x i33> [[C]]
39 %B = shl <2 x i33> %A, <i33 5, i33 5>
40 %C = shl <2 x i33> %B, <i33 28, i33 28>
46 define <2 x i33> @shl_shl_vec(<2 x i33> %A) {
47 ; CHECK-LABEL: @shl_shl_vec(
48 ; CHECK-NEXT: [[B:%.*]] = shl <2 x i33> [[A:%.*]], <i33 6, i33 5>
49 ; CHECK-NEXT: [[C:%.*]] = shl <2 x i33> [[B]], <i33 27, i33 28>
50 ; CHECK-NEXT: ret <2 x i33> [[C]]
52 %B = shl <2 x i33> %A, <i33 6, i33 5>
53 %C = shl <2 x i33> %B, <i33 27, i33 28>
57 define i232 @lshr_lshr(i232 %A) {
58 ; CHECK-LABEL: @lshr_lshr(
59 ; CHECK-NEXT: [[B:%.*]] = lshr i232 [[A:%.*]], 231
60 ; CHECK-NEXT: [[C:%.*]] = lshr i232 [[B]], 1
61 ; CHECK-NEXT: ret i232 [[C]]
63 %B = lshr i232 %A, 231
68 define <2 x i32> @lshr_lshr_splat_vec(<2 x i32> %A) {
69 ; CHECK-LABEL: @lshr_lshr_splat_vec(
70 ; CHECK-NEXT: [[B:%.*]] = lshr <2 x i32> [[A:%.*]], <i32 28, i32 28>
71 ; CHECK-NEXT: [[C:%.*]] = lshr <2 x i32> [[B]], <i32 4, i32 4>
72 ; CHECK-NEXT: ret <2 x i32> [[C]]
74 %B = lshr <2 x i32> %A, <i32 28, i32 28>
75 %C = lshr <2 x i32> %B, <i32 4, i32 4>
79 define <2 x i32> @lshr_lshr_vec(<2 x i32> %A) {
80 ; CHECK-LABEL: @lshr_lshr_vec(
81 ; CHECK-NEXT: [[B:%.*]] = lshr <2 x i32> [[A:%.*]], <i32 29, i32 28>
82 ; CHECK-NEXT: [[C:%.*]] = lshr <2 x i32> [[B]], <i32 4, i32 5>
83 ; CHECK-NEXT: ret <2 x i32> [[C]]
85 %B = lshr <2 x i32> %A, <i32 29, i32 28>
86 %C = lshr <2 x i32> %B, <i32 4, i32 5>