OLD | NEW |
1 ; Tests various aspects of i1 related lowering. | 1 ; Tests various aspects of i1 related lowering. |
2 | 2 |
3 ; RUN: %p2i -i %s -a -O2 --verbose none \ | 3 ; RUN: %p2i -i %s --assemble --disassemble -a -O2 --verbose none \ |
4 ; RUN: | llvm-mc -triple=i686-none-nacl -filetype=obj \ | 4 ; RUN: | FileCheck %s |
5 ; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s | 5 ; RUN: %p2i -i %s --assemble --disassemble -a -Om1 --verbose none \ |
6 ; RUN: %p2i -i %s -a -Om1 --verbose none \ | 6 ; RUN: | FileCheck %s |
7 ; RUN: | llvm-mc -triple=i686-none-nacl -filetype=obj \ | |
8 ; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s | |
9 | 7 |
10 ; Test that and with true uses immediate 1, not -1. | 8 ; Test that and with true uses immediate 1, not -1. |
11 define internal i32 @testAndTrue(i32 %arg) { | 9 define internal i32 @testAndTrue(i32 %arg) { |
12 entry: | 10 entry: |
13 %arg_i1 = trunc i32 %arg to i1 | 11 %arg_i1 = trunc i32 %arg to i1 |
14 %result_i1 = and i1 %arg_i1, true | 12 %result_i1 = and i1 %arg_i1, true |
15 %result = zext i1 %result_i1 to i32 | 13 %result = zext i1 %result_i1 to i32 |
16 ret i32 %result | 14 ret i32 %result |
17 } | 15 } |
18 ; CHECK-LABEL: testAndTrue | 16 ; CHECK-LABEL: testAndTrue |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 entry: | 67 entry: |
70 %arg_i1 = trunc i32 %arg to i1 | 68 %arg_i1 = trunc i32 %arg to i1 |
71 %result_i16 = zext i1 %arg_i1 to i16 | 69 %result_i16 = zext i1 %arg_i1 to i16 |
72 %result = zext i16 %result_i16 to i32 | 70 %result = zext i16 %result_i16 to i32 |
73 ret i32 %result | 71 ret i32 %result |
74 } | 72 } |
75 ; CHECK-LABEL: testZextI16 | 73 ; CHECK-LABEL: testZextI16 |
76 ; match the trunc instruction | 74 ; match the trunc instruction |
77 ; CHECK: and {{.*}}, 1 | 75 ; CHECK: and {{.*}}, 1 |
78 ; match the zext i1 instruction (note 32-bit reg is used because it's shorter). | 76 ; match the zext i1 instruction (note 32-bit reg is used because it's shorter). |
79 ; CHECK: movzx [[REG:e.*]], {{[a-d]l|byte ptr}} | 77 ; CHECK: movzx [[REG:e.*]],{{[a-d]l|BYTE PTR}} |
80 ; CHECK: and [[REG]], 1 | 78 ; CHECK: and [[REG]], 1 |
81 | 79 |
82 ; Test zext to i32. | 80 ; Test zext to i32. |
83 define internal i32 @testZextI32(i32 %arg) { | 81 define internal i32 @testZextI32(i32 %arg) { |
84 entry: | 82 entry: |
85 %arg_i1 = trunc i32 %arg to i1 | 83 %arg_i1 = trunc i32 %arg to i1 |
86 %result_i32 = zext i1 %arg_i1 to i32 | 84 %result_i32 = zext i1 %arg_i1 to i32 |
87 ret i32 %result_i32 | 85 ret i32 %result_i32 |
88 } | 86 } |
89 ; CHECK-LABEL: testZextI32 | 87 ; CHECK-LABEL: testZextI32 |
90 ; match the trunc instruction | 88 ; match the trunc instruction |
91 ; CHECK: and {{.*}}, 1 | 89 ; CHECK: and {{.*}}, 1 |
92 ; match the zext i1 instruction | 90 ; match the zext i1 instruction |
93 ; CHECK: movzx | 91 ; CHECK: movzx |
94 ; CHECK: and {{.*}}, 1 | 92 ; CHECK: and {{.*}}, 1 |
95 | 93 |
96 ; Test zext to i64. | 94 ; Test zext to i64. |
97 define internal i64 @testZextI64(i32 %arg) { | 95 define internal i64 @testZextI64(i32 %arg) { |
98 entry: | 96 entry: |
99 %arg_i1 = trunc i32 %arg to i1 | 97 %arg_i1 = trunc i32 %arg to i1 |
100 %result_i64 = zext i1 %arg_i1 to i64 | 98 %result_i64 = zext i1 %arg_i1 to i64 |
101 ret i64 %result_i64 | 99 ret i64 %result_i64 |
102 } | 100 } |
103 ; CHECK-LABEL: testZextI64 | 101 ; CHECK-LABEL: testZextI64 |
104 ; match the trunc instruction | 102 ; match the trunc instruction |
105 ; CHECK: and {{.*}}, 1 | 103 ; CHECK: and {{.*}}, 1 |
106 ; match the zext i1 instruction | 104 ; match the zext i1 instruction |
107 ; CHECK: movzx | 105 ; CHECK: movzx |
108 ; CHECK: and {{.*}}, 1 | 106 ; CHECK: and {{.*}}, 1 |
109 ; CHECK: mov {{.*}}, 0 | 107 ; CHECK: mov {{.*}},0 |
110 | 108 |
111 ; Test sext to i8. | 109 ; Test sext to i8. |
112 define internal i32 @testSextI8(i32 %arg) { | 110 define internal i32 @testSextI8(i32 %arg) { |
113 entry: | 111 entry: |
114 %arg_i1 = trunc i32 %arg to i1 | 112 %arg_i1 = trunc i32 %arg to i1 |
115 %result_i8 = sext i1 %arg_i1 to i8 | 113 %result_i8 = sext i1 %arg_i1 to i8 |
116 %result = sext i8 %result_i8 to i32 | 114 %result = sext i8 %result_i8 to i32 |
117 ret i32 %result | 115 ret i32 %result |
118 } | 116 } |
119 ; CHECK-LABEL: testSextI8 | 117 ; CHECK-LABEL: testSextI8 |
120 ; match the trunc instruction | 118 ; match the trunc instruction |
121 ; CHECK: and {{.*}}, 1 | 119 ; CHECK: and {{.*}}, 1 |
122 ; match the sext i1 instruction | 120 ; match the sext i1 instruction |
123 ; CHECK: shl [[REG:.*]], 7 | 121 ; CHECK: shl [[REG:.*]], 7 |
124 ; CHECK-NEXT: sar [[REG]], 7 | 122 ; CHECK-NEXT: sar [[REG]], 7 |
125 | 123 |
126 ; Test sext to i16. | 124 ; Test sext to i16. |
127 define internal i32 @testSextI16(i32 %arg) { | 125 define internal i32 @testSextI16(i32 %arg) { |
128 entry: | 126 entry: |
129 %arg_i1 = trunc i32 %arg to i1 | 127 %arg_i1 = trunc i32 %arg to i1 |
130 %result_i16 = sext i1 %arg_i1 to i16 | 128 %result_i16 = sext i1 %arg_i1 to i16 |
131 %result = sext i16 %result_i16 to i32 | 129 %result = sext i16 %result_i16 to i32 |
132 ret i32 %result | 130 ret i32 %result |
133 } | 131 } |
134 ; CHECK-LABEL: testSextI16 | 132 ; CHECK-LABEL: testSextI16 |
135 ; match the trunc instruction | 133 ; match the trunc instruction |
136 ; CHECK: and {{.*}}, 1 | 134 ; CHECK: and {{.*}}, 1 |
137 ; match the sext i1 instruction | 135 ; match the sext i1 instruction |
138 ; CHECK: movzx e[[REG:.*]], {{[a-d]l|byte ptr}} | 136 ; CHECK: movzx e[[REG:.*]],{{[a-d]l|BYTE PTR}} |
139 ; CHECK-NEXT: shl [[REG]], 15 | 137 ; CHECK-NEXT: shl [[REG]], 15 |
140 ; CHECK-NEXT: sar [[REG]], 15 | 138 ; CHECK-NEXT: sar [[REG]], 15 |
141 | 139 |
142 ; Test sext to i32. | 140 ; Test sext to i32. |
143 define internal i32 @testSextI32(i32 %arg) { | 141 define internal i32 @testSextI32(i32 %arg) { |
144 entry: | 142 entry: |
145 %arg_i1 = trunc i32 %arg to i1 | 143 %arg_i1 = trunc i32 %arg to i1 |
146 %result_i32 = sext i1 %arg_i1 to i32 | 144 %result_i32 = sext i1 %arg_i1 to i32 |
147 ret i32 %result_i32 | 145 ret i32 %result_i32 |
148 } | 146 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 %arg_i1 = fptosi double %arg to i1 | 187 %arg_i1 = fptosi double %arg to i1 |
190 %result = sext i1 %arg_i1 to i32 | 188 %result = sext i1 %arg_i1 to i32 |
191 ret i32 %result | 189 ret i32 %result |
192 } | 190 } |
193 ; CHECK-LABEL: testFptosiDouble | 191 ; CHECK-LABEL: testFptosiDouble |
194 ; CHECK: cvttsd2si | 192 ; CHECK: cvttsd2si |
195 ; CHECK: and {{.*}}, 1 | 193 ; CHECK: and {{.*}}, 1 |
196 ; CHECK: movzx [[REG:.*]], | 194 ; CHECK: movzx [[REG:.*]], |
197 ; CHECK-NEXT: shl [[REG]], 31 | 195 ; CHECK-NEXT: shl [[REG]], 31 |
198 ; CHECK-NEXT: sar [[REG]], 31 | 196 ; CHECK-NEXT: sar [[REG]], 31 |
OLD | NEW |