150
|
1 ; RUN: opt < %s -codegenprepare -S -mtriple=x86_64-unknown-unknown | FileCheck %s
|
|
2
|
|
3
|
|
4 @a = global [10 x i8] zeroinitializer, align 1
|
|
5 declare void @foo()
|
|
6
|
|
7 ; ext(and(ld, cst)) -> and(ext(ld), ext(cst))
|
|
8 define void @test1(i32* %p, i32 %ll) {
|
|
9 ; CHECK-LABEL: @test1
|
|
10 ; CHECK-NEXT: entry:
|
|
11 ; CHECK-NEXT: load
|
|
12 ; CHECK-NEXT: zext
|
|
13 ; CHECK-NEXT: and
|
|
14 entry:
|
|
15 %tmp = load i8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @a, i64 0, i64 0), align 1
|
|
16 %and = and i8 %tmp, 60
|
|
17 %cmp = icmp ugt i8 %and, 20
|
|
18 br i1 %cmp, label %if.then, label %if.end
|
|
19
|
|
20 if.then: ; preds = %entry
|
|
21 %conv2 = zext i8 %and to i32
|
|
22 %add = add nsw i32 %conv2, %ll
|
|
23 store i32 %add, i32* %p, align 4
|
|
24 br label %if.end
|
|
25
|
|
26 if.end: ; preds = %if.then, %entry
|
|
27 tail call void @foo()
|
|
28 ret void
|
|
29 }
|
|
30
|
|
31 ; ext(or(ld, cst)) -> or(ext(ld), ext(cst))
|
|
32 define void @test2(i32* %p, i32 %ll) {
|
|
33 ; CHECK-LABEL: @test2
|
|
34 ; CHECK-NEXT: entry:
|
|
35 ; CHECK-NEXT: load
|
|
36 ; CHECK-NEXT: zext
|
|
37 ; CHECK-NEXT: or
|
|
38 entry:
|
|
39 %tmp = load i8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @a, i64 0, i64 0), align 1
|
|
40 %or = or i8 %tmp, 60
|
|
41 %cmp = icmp ugt i8 %or, 20
|
|
42 br i1 %cmp, label %if.then, label %if.end
|
|
43
|
|
44 if.then: ; preds = %entry
|
|
45 %conv2 = zext i8 %or to i32
|
|
46 %add = add nsw i32 %conv2, %ll
|
|
47 store i32 %add, i32* %p, align 4
|
|
48 br label %if.end
|
|
49
|
|
50 if.end: ; preds = %if.then, %entry
|
|
51 tail call void @foo()
|
|
52 ret void
|
|
53 }
|
|
54
|
|
55 ; ext(and(shl(ld, cst), cst)) -> and(shl(ext(ld), ext(cst)), ext(cst))
|
|
56 define void @test3(i32* %p, i32 %ll) {
|
|
57 ; CHECK-LABEL: @test3
|
|
58 ; CHECK-NEXT: entry:
|
|
59 ; CHECK-NEXT: load
|
|
60 ; CHECK-NEXT: zext
|
|
61 ; CHECK-NEXT: shl
|
|
62 ; CHECK-NEXT: and
|
|
63 entry:
|
|
64 %tmp = load i8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @a, i64 0, i64 0), align 1
|
|
65 %shl = shl i8 %tmp, 2
|
|
66 %and = and i8 %shl, 60
|
|
67 %cmp = icmp ugt i8 %and, 20
|
|
68 br i1 %cmp, label %if.then, label %if.end
|
|
69
|
|
70 if.then: ; preds = %entry
|
|
71 %conv2 = zext i8 %and to i32
|
|
72 %add = add nsw i32 %conv2, %ll
|
|
73 store i32 %add, i32* %p, align 4
|
|
74 br label %if.end
|
|
75
|
|
76 if.end: ; preds = %if.then, %entry
|
|
77 tail call void @foo()
|
|
78 ret void
|
|
79 }
|
|
80
|
|
81 ; zext(shrl(ld, cst)) -> shrl(zext(ld), zext(cst))
|
|
82 define void @test4(i32* %p, i32 %ll) {
|
|
83 ; CHECK-LABEL: @test4
|
|
84 ; CHECK-NEXT: entry:
|
|
85 ; CHECK-NEXT: load
|
|
86 ; CHECK-NEXT: zext
|
|
87 ; CHECK-NEXT: lshr
|
|
88 entry:
|
|
89 %tmp = load i8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @a, i64 0, i64 0), align 1
|
|
90 %lshr = lshr i8 %tmp, 2
|
|
91 %cmp = icmp ugt i8 %lshr, 20
|
|
92 br i1 %cmp, label %if.then, label %if.end
|
|
93
|
|
94 if.then: ; preds = %entry
|
|
95 %conv2 = zext i8 %lshr to i32
|
|
96 %add = add nsw i32 %conv2, %ll
|
|
97 store i32 %add, i32* %p, align 4
|
|
98 br label %if.end
|
|
99
|
|
100 if.end: ; preds = %if.then, %entry
|
|
101 tail call void @foo()
|
|
102 ret void
|
|
103 }
|
|
104
|
|
105 ; ext(xor(ld, cst)) -> xor(ext(ld), ext(cst))
|
|
106 define void @test5(i32* %p, i32 %ll) {
|
|
107 ; CHECK-LABEL: @test5
|
|
108 ; CHECK-NEXT: entry:
|
|
109 ; CHECK-NEXT: load
|
|
110 ; CHECK-NEXT: zext
|
|
111 ; CHECK-NEXT: xor
|
|
112 entry:
|
|
113 %tmp = load i8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @a, i64 0, i64 0), align 1
|
|
114 %xor = xor i8 %tmp, 60
|
|
115 %cmp = icmp ugt i8 %xor, 20
|
|
116 br i1 %cmp, label %if.then, label %if.end
|
|
117
|
|
118 if.then: ; preds = %entry
|
|
119 %conv2 = zext i8 %xor to i32
|
|
120 %add = add nsw i32 %conv2, %ll
|
|
121 store i32 %add, i32* %p, align 4
|
|
122 br label %if.end
|
|
123
|
|
124 if.end: ; preds = %if.then, %entry
|
|
125 tail call void @foo()
|
|
126 ret void
|
|
127 }
|
|
128
|