@@ -7,6 +7,92 @@ declare void @use32(i32)
7
7
8
8
; There should be no 'and' instructions left in any test.
9
9
10
+ define i32 @test_with_1 (i32 %x ) {
11
+ ; CHECK-LABEL: @test_with_1(
12
+ ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[X:%.*]], 0
13
+ ; CHECK-NEXT: [[AND:%.*]] = zext i1 [[TMP1]] to i32
14
+ ; CHECK-NEXT: ret i32 [[AND]]
15
+ ;
16
+ %shl = shl i32 1 , %x
17
+ %and = and i32 %shl , 1
18
+ ret i32 %and
19
+ }
20
+
21
+ define i32 @test_with_3 (i32 %x ) {
22
+ ; CHECK-LABEL: @test_with_3(
23
+ ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[X:%.*]], 0
24
+ ; CHECK-NEXT: [[AND:%.*]] = zext i1 [[TMP1]] to i32
25
+ ; CHECK-NEXT: ret i32 [[AND]]
26
+ ;
27
+ %shl = shl i32 3 , %x
28
+ %and = and i32 %shl , 1
29
+ ret i32 %and
30
+ }
31
+
32
+ define i32 @test_with_5 (i32 %x ) {
33
+ ; CHECK-LABEL: @test_with_5(
34
+ ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[X:%.*]], 0
35
+ ; CHECK-NEXT: [[AND:%.*]] = zext i1 [[TMP1]] to i32
36
+ ; CHECK-NEXT: ret i32 [[AND]]
37
+ ;
38
+ %shl = shl i32 5 , %x
39
+ %and = and i32 %shl , 1
40
+ ret i32 %and
41
+ }
42
+
43
+ define i32 @test_with_neg_5 (i32 %x ) {
44
+ ; CHECK-LABEL: @test_with_neg_5(
45
+ ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[X:%.*]], 0
46
+ ; CHECK-NEXT: [[AND:%.*]] = zext i1 [[TMP1]] to i32
47
+ ; CHECK-NEXT: ret i32 [[AND]]
48
+ ;
49
+ %shl = shl i32 -5 , %x
50
+ %and = and i32 %shl , 1
51
+ ret i32 %and
52
+ }
53
+
54
+ define i32 @test_with_even (i32 %x ) {
55
+ ; CHECK-LABEL: @test_with_even(
56
+ ; CHECK-NEXT: ret i32 0
57
+ ;
58
+ %shl = shl i32 4 , %x
59
+ %and = and i32 %shl , 1
60
+ ret i32 %and
61
+ }
62
+
63
+ define <2 x i32 > @test_vec (<2 x i32 > %x ) {
64
+ ; CHECK-LABEL: @test_vec(
65
+ ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq <2 x i32> [[X:%.*]], zeroinitializer
66
+ ; CHECK-NEXT: [[AND:%.*]] = zext <2 x i1> [[TMP1]] to <2 x i32>
67
+ ; CHECK-NEXT: ret <2 x i32> [[AND]]
68
+ ;
69
+ %shl = shl <2 x i32 > <i32 5 , i32 5 >, %x
70
+ %and = and <2 x i32 > %shl , <i32 1 , i32 1 >
71
+ ret <2 x i32 > %and
72
+ }
73
+
74
+ define i32 @test_with_neg_even (i32 %x ) {
75
+ ; CHECK-LABEL: @test_with_neg_even(
76
+ ; CHECK-NEXT: ret i32 0
77
+ ;
78
+ %shl = shl i32 -4 , %x
79
+ %and = and i32 %shl , 1
80
+ ret i32 %and
81
+ }
82
+
83
+ define i32 @test_with_more_one_use (i32 %x ) {
84
+ ; CHECK-LABEL: @test_with_more_one_use(
85
+ ; CHECK-NEXT: [[SHL:%.*]] = shl i32 7, [[X:%.*]]
86
+ ; CHECK-NEXT: [[AND:%.*]] = and i32 [[SHL]], 1
87
+ ; CHECK-NEXT: call void @use32(i32 [[SHL]])
88
+ ; CHECK-NEXT: ret i32 [[AND]]
89
+ ;
90
+ %shl = shl i32 7 , %x
91
+ %and = and i32 %shl , 1
92
+ call void @use32 (i32 %shl )
93
+ ret i32 %and
94
+ }
95
+
10
96
define i32 @test1 (i32 %A ) {
11
97
; CHECK-LABEL: @test1(
12
98
; CHECK-NEXT: ret i32 0
0 commit comments