Evan Cheng | f2d36d9 | 2010-04-30 06:00:56 +0000 | [diff] [blame] | 1 | ; RUN: llc < %s -march=x86 -mattr=+sse2 -asm-verbose=false | FileCheck %s -check-prefix=32 |
| 2 | ; RUN: llc < %s -march=x86-64 -mattr=+sse2 -asm-verbose=false | FileCheck %s -check-prefix=64 |
Dale Johannesen | a01818c | 2010-08-15 19:40:29 +0000 | [diff] [blame] | 3 | ; Darwin 8 generates stubs, which don't match |
| 4 | ; XFAIL: apple-darwin8 |
Evan Cheng | b171245 | 2010-01-27 06:25:16 +0000 | [diff] [blame] | 5 | |
Evan Cheng | 7096ae4 | 2010-01-29 06:45:59 +0000 | [diff] [blame] | 6 | define void @t1(i32 %x) nounwind ssp { |
Evan Cheng | b171245 | 2010-01-27 06:25:16 +0000 | [diff] [blame] | 7 | entry: |
Evan Cheng | a6bff98 | 2010-01-30 01:22:00 +0000 | [diff] [blame] | 8 | ; 32: t1: |
| 9 | ; 32: jmp {{_?}}foo |
| 10 | |
| 11 | ; 64: t1: |
| 12 | ; 64: jmp {{_?}}foo |
Evan Cheng | b171245 | 2010-01-27 06:25:16 +0000 | [diff] [blame] | 13 | tail call void @foo() nounwind |
| 14 | ret void |
| 15 | } |
| 16 | |
| 17 | declare void @foo() |
Evan Cheng | 7096ae4 | 2010-01-29 06:45:59 +0000 | [diff] [blame] | 18 | |
| 19 | define void @t2() nounwind ssp { |
| 20 | entry: |
Evan Cheng | a6bff98 | 2010-01-30 01:22:00 +0000 | [diff] [blame] | 21 | ; 32: t2: |
| 22 | ; 32: jmp {{_?}}foo2 |
| 23 | |
| 24 | ; 64: t2: |
| 25 | ; 64: jmp {{_?}}foo2 |
Evan Cheng | 7096ae4 | 2010-01-29 06:45:59 +0000 | [diff] [blame] | 26 | %0 = tail call i32 @foo2() nounwind |
| 27 | ret void |
| 28 | } |
| 29 | |
| 30 | declare i32 @foo2() |
| 31 | |
| 32 | define void @t3() nounwind ssp { |
| 33 | entry: |
Evan Cheng | a6bff98 | 2010-01-30 01:22:00 +0000 | [diff] [blame] | 34 | ; 32: t3: |
| 35 | ; 32: jmp {{_?}}foo3 |
| 36 | |
| 37 | ; 64: t3: |
| 38 | ; 64: jmp {{_?}}foo3 |
Evan Cheng | 7096ae4 | 2010-01-29 06:45:59 +0000 | [diff] [blame] | 39 | %0 = tail call i32 @foo3() nounwind |
| 40 | ret void |
| 41 | } |
| 42 | |
| 43 | declare i32 @foo3() |
Evan Cheng | a6bff98 | 2010-01-30 01:22:00 +0000 | [diff] [blame] | 44 | |
| 45 | define void @t4(void (i32)* nocapture %x) nounwind ssp { |
| 46 | entry: |
| 47 | ; 32: t4: |
| 48 | ; 32: call * |
| 49 | ; FIXME: gcc can generate a tailcall for this. But it's tricky. |
| 50 | |
| 51 | ; 64: t4: |
| 52 | ; 64-NOT: call |
| 53 | ; 64: jmpq * |
| 54 | tail call void %x(i32 0) nounwind |
| 55 | ret void |
| 56 | } |
| 57 | |
| 58 | define void @t5(void ()* nocapture %x) nounwind ssp { |
| 59 | entry: |
| 60 | ; 32: t5: |
| 61 | ; 32-NOT: call |
Evan Cheng | 1ad584e | 2010-03-20 03:17:05 +0000 | [diff] [blame] | 62 | ; 32: jmpl *4(%esp) |
Evan Cheng | a6bff98 | 2010-01-30 01:22:00 +0000 | [diff] [blame] | 63 | |
| 64 | ; 64: t5: |
| 65 | ; 64-NOT: call |
Evan Cheng | 1ad584e | 2010-03-20 03:17:05 +0000 | [diff] [blame] | 66 | ; 64: jmpq *%rdi |
Evan Cheng | a6bff98 | 2010-01-30 01:22:00 +0000 | [diff] [blame] | 67 | tail call void %x() nounwind |
| 68 | ret void |
| 69 | } |
Evan Cheng | 843bd69 | 2010-01-31 06:44:49 +0000 | [diff] [blame] | 70 | |
| 71 | define i32 @t6(i32 %x) nounwind ssp { |
| 72 | entry: |
| 73 | ; 32: t6: |
| 74 | ; 32: call {{_?}}t6 |
Evan Cheng | 5f94193 | 2010-02-05 02:21:12 +0000 | [diff] [blame] | 75 | ; 32: jmp {{_?}}bar |
Evan Cheng | 843bd69 | 2010-01-31 06:44:49 +0000 | [diff] [blame] | 76 | |
| 77 | ; 64: t6: |
Evan Cheng | 0a4fd46 | 2010-02-01 02:13:39 +0000 | [diff] [blame] | 78 | ; 64: jmp {{_?}}t6 |
Evan Cheng | 843bd69 | 2010-01-31 06:44:49 +0000 | [diff] [blame] | 79 | ; 64: jmp {{_?}}bar |
| 80 | %0 = icmp slt i32 %x, 10 |
| 81 | br i1 %0, label %bb, label %bb1 |
| 82 | |
| 83 | bb: |
| 84 | %1 = add nsw i32 %x, -1 |
| 85 | %2 = tail call i32 @t6(i32 %1) nounwind ssp |
| 86 | ret i32 %2 |
| 87 | |
| 88 | bb1: |
| 89 | %3 = tail call i32 @bar(i32 %x) nounwind |
| 90 | ret i32 %3 |
| 91 | } |
| 92 | |
| 93 | declare i32 @bar(i32) |
Evan Cheng | b2c9290 | 2010-02-02 02:22:50 +0000 | [diff] [blame] | 94 | |
| 95 | define i32 @t7(i32 %a, i32 %b, i32 %c) nounwind ssp { |
| 96 | entry: |
| 97 | ; 32: t7: |
| 98 | ; 32: jmp {{_?}}bar2 |
| 99 | |
| 100 | ; 64: t7: |
| 101 | ; 64: jmp {{_?}}bar2 |
| 102 | %0 = tail call i32 @bar2(i32 %a, i32 %b, i32 %c) nounwind |
| 103 | ret i32 %0 |
| 104 | } |
| 105 | |
| 106 | declare i32 @bar2(i32, i32, i32) |
Evan Cheng | 86809cc | 2010-02-03 03:28:02 +0000 | [diff] [blame] | 107 | |
| 108 | define signext i16 @t8() nounwind ssp { |
| 109 | entry: |
| 110 | ; 32: t8: |
Evan Cheng | 1f2fda9 | 2010-02-04 06:47:24 +0000 | [diff] [blame] | 111 | ; 32: call {{_?}}bar3 |
Evan Cheng | 86809cc | 2010-02-03 03:28:02 +0000 | [diff] [blame] | 112 | |
| 113 | ; 64: t8: |
Evan Cheng | 1f2fda9 | 2010-02-04 06:47:24 +0000 | [diff] [blame] | 114 | ; 64: callq {{_?}}bar3 |
Evan Cheng | 86809cc | 2010-02-03 03:28:02 +0000 | [diff] [blame] | 115 | %0 = tail call signext i16 @bar3() nounwind ; <i16> [#uses=1] |
| 116 | ret i16 %0 |
| 117 | } |
| 118 | |
| 119 | declare signext i16 @bar3() |
| 120 | |
| 121 | define signext i16 @t9(i32 (i32)* nocapture %x) nounwind ssp { |
| 122 | entry: |
| 123 | ; 32: t9: |
| 124 | ; 32: call * |
| 125 | |
| 126 | ; 64: t9: |
| 127 | ; 64: callq * |
| 128 | %0 = bitcast i32 (i32)* %x to i16 (i32)* |
| 129 | %1 = tail call signext i16 %0(i32 0) nounwind |
| 130 | ret i16 %1 |
| 131 | } |
Evan Cheng | febc816 | 2010-02-03 03:55:59 +0000 | [diff] [blame] | 132 | |
| 133 | define void @t10() nounwind ssp { |
| 134 | entry: |
| 135 | ; 32: t10: |
| 136 | ; 32: call |
| 137 | |
| 138 | ; 64: t10: |
| 139 | ; 64: callq |
| 140 | %0 = tail call i32 @foo4() noreturn nounwind |
| 141 | unreachable |
| 142 | } |
| 143 | |
| 144 | declare i32 @foo4() |
Evan Cheng | 5f94193 | 2010-02-05 02:21:12 +0000 | [diff] [blame] | 145 | |
| 146 | define i32 @t11(i32 %x, i32 %y, i32 %z.0, i32 %z.1, i32 %z.2) nounwind ssp { |
| 147 | ; In 32-bit mode, it's emitting a bunch of dead loads that are not being |
| 148 | ; eliminated currently. |
| 149 | |
| 150 | ; 32: t11: |
Evan Cheng | f22f9b3 | 2010-02-06 03:28:46 +0000 | [diff] [blame] | 151 | ; 32-NOT: subl ${{[0-9]+}}, %esp |
Evan Cheng | 00a99a3 | 2010-02-06 09:07:11 +0000 | [diff] [blame] | 152 | ; 32: jne |
| 153 | ; 32-NOT: movl |
Evan Cheng | f22f9b3 | 2010-02-06 03:28:46 +0000 | [diff] [blame] | 154 | ; 32-NOT: addl ${{[0-9]+}}, %esp |
Evan Cheng | 5f94193 | 2010-02-05 02:21:12 +0000 | [diff] [blame] | 155 | ; 32: jmp {{_?}}foo5 |
| 156 | |
| 157 | ; 64: t11: |
Evan Cheng | f22f9b3 | 2010-02-06 03:28:46 +0000 | [diff] [blame] | 158 | ; 64-NOT: subq ${{[0-9]+}}, %esp |
| 159 | ; 64-NOT: addq ${{[0-9]+}}, %esp |
Evan Cheng | 5f94193 | 2010-02-05 02:21:12 +0000 | [diff] [blame] | 160 | ; 64: jmp {{_?}}foo5 |
| 161 | entry: |
| 162 | %0 = icmp eq i32 %x, 0 |
| 163 | br i1 %0, label %bb6, label %bb |
| 164 | |
| 165 | bb: |
| 166 | %1 = tail call i32 @foo5(i32 %x, i32 %y, i32 %z.0, i32 %z.1, i32 %z.2) nounwind |
| 167 | ret i32 %1 |
| 168 | |
| 169 | bb6: |
| 170 | ret i32 0 |
| 171 | } |
| 172 | |
| 173 | declare i32 @foo5(i32, i32, i32, i32, i32) |
| 174 | |
| 175 | %struct.t = type { i32, i32, i32, i32, i32 } |
| 176 | |
| 177 | define i32 @t12(i32 %x, i32 %y, %struct.t* byval align 4 %z) nounwind ssp { |
| 178 | ; 32: t12: |
Evan Cheng | f22f9b3 | 2010-02-06 03:28:46 +0000 | [diff] [blame] | 179 | ; 32-NOT: subl ${{[0-9]+}}, %esp |
| 180 | ; 32-NOT: addl ${{[0-9]+}}, %esp |
Evan Cheng | 5f94193 | 2010-02-05 02:21:12 +0000 | [diff] [blame] | 181 | ; 32: jmp {{_?}}foo6 |
| 182 | |
| 183 | ; 64: t12: |
Evan Cheng | f22f9b3 | 2010-02-06 03:28:46 +0000 | [diff] [blame] | 184 | ; 64-NOT: subq ${{[0-9]+}}, %esp |
| 185 | ; 64-NOT: addq ${{[0-9]+}}, %esp |
Evan Cheng | 5f94193 | 2010-02-05 02:21:12 +0000 | [diff] [blame] | 186 | ; 64: jmp {{_?}}foo6 |
| 187 | entry: |
| 188 | %0 = icmp eq i32 %x, 0 |
| 189 | br i1 %0, label %bb2, label %bb |
| 190 | |
| 191 | bb: |
| 192 | %1 = tail call i32 @foo6(i32 %x, i32 %y, %struct.t* byval align 4 %z) nounwind |
| 193 | ret i32 %1 |
| 194 | |
| 195 | bb2: |
| 196 | ret i32 0 |
| 197 | } |
| 198 | |
| 199 | declare i32 @foo6(i32, i32, %struct.t* byval align 4) |
Evan Cheng | 4cae133 | 2010-03-05 08:38:04 +0000 | [diff] [blame] | 200 | |
| 201 | ; rdar://r7717598 |
| 202 | %struct.ns = type { i32, i32 } |
| 203 | %struct.cp = type { float, float } |
| 204 | |
| 205 | define %struct.ns* @t13(%struct.cp* %yy) nounwind ssp { |
| 206 | ; 32: t13: |
| 207 | ; 32-NOT: jmp |
| 208 | ; 32: call |
| 209 | ; 32: ret |
| 210 | |
| 211 | ; 64: t13: |
| 212 | ; 64-NOT: jmp |
| 213 | ; 64: call |
| 214 | ; 64: ret |
| 215 | entry: |
| 216 | %0 = tail call fastcc %struct.ns* @foo7(%struct.cp* byval align 4 %yy, i8 signext 0) nounwind |
| 217 | ret %struct.ns* %0 |
| 218 | } |
| 219 | |
Evan Cheng | 1ad584e | 2010-03-20 03:17:05 +0000 | [diff] [blame] | 220 | ; rdar://6195379 |
| 221 | ; llvm can't do sibcall for this in 32-bit mode (yet). |
Evan Cheng | 4cae133 | 2010-03-05 08:38:04 +0000 | [diff] [blame] | 222 | declare fastcc %struct.ns* @foo7(%struct.cp* byval align 4, i8 signext) nounwind ssp |
Evan Cheng | 1ad584e | 2010-03-20 03:17:05 +0000 | [diff] [blame] | 223 | |
| 224 | %struct.__block_descriptor = type { i64, i64 } |
| 225 | %struct.__block_descriptor_withcopydispose = type { i64, i64, i8*, i8* } |
| 226 | %struct.__block_literal_1 = type { i8*, i32, i32, i8*, %struct.__block_descriptor* } |
| 227 | %struct.__block_literal_2 = type { i8*, i32, i32, i8*, %struct.__block_descriptor_withcopydispose*, void ()* } |
| 228 | |
| 229 | define void @t14(%struct.__block_literal_2* nocapture %.block_descriptor) nounwind ssp { |
| 230 | entry: |
| 231 | ; 64: t14: |
| 232 | ; 64: movq 32(%rdi) |
| 233 | ; 64-NOT: movq 16(%rdi) |
| 234 | ; 64: jmpq *16(%rdi) |
| 235 | %0 = getelementptr inbounds %struct.__block_literal_2* %.block_descriptor, i64 0, i32 5 ; <void ()**> [#uses=1] |
| 236 | %1 = load void ()** %0, align 8 ; <void ()*> [#uses=2] |
| 237 | %2 = bitcast void ()* %1 to %struct.__block_literal_1* ; <%struct.__block_literal_1*> [#uses=1] |
| 238 | %3 = getelementptr inbounds %struct.__block_literal_1* %2, i64 0, i32 3 ; <i8**> [#uses=1] |
| 239 | %4 = load i8** %3, align 8 ; <i8*> [#uses=1] |
| 240 | %5 = bitcast i8* %4 to void (i8*)* ; <void (i8*)*> [#uses=1] |
| 241 | %6 = bitcast void ()* %1 to i8* ; <i8*> [#uses=1] |
| 242 | tail call void %5(i8* %6) nounwind |
| 243 | ret void |
| 244 | } |
| 245 | |
| 246 | ; rdar://7726868 |
| 247 | %struct.foo = type { [4 x i32] } |
| 248 | |
| 249 | define void @t15(%struct.foo* noalias sret %agg.result) nounwind { |
| 250 | ; 32: t15: |
| 251 | ; 32: call {{_?}}f |
| 252 | ; 32: ret $4 |
| 253 | |
| 254 | ; 64: t15: |
| 255 | ; 64: callq {{_?}}f |
| 256 | ; 64: ret |
| 257 | tail call fastcc void @f(%struct.foo* noalias sret %agg.result) nounwind |
| 258 | ret void |
| 259 | } |
| 260 | |
| 261 | declare void @f(%struct.foo* noalias sret) nounwind |
| 262 | |
| 263 | define void @t16() nounwind ssp { |
| 264 | entry: |
| 265 | ; 32: t16: |
| 266 | ; 32: call {{_?}}bar4 |
| 267 | ; 32: fstp |
| 268 | |
| 269 | ; 64: t16: |
| 270 | ; 64: jmp {{_?}}bar4 |
| 271 | %0 = tail call double @bar4() nounwind |
| 272 | ret void |
| 273 | } |
| 274 | |
| 275 | declare double @bar4() |
Evan Cheng | 3c262ee | 2010-03-26 02:13:13 +0000 | [diff] [blame] | 276 | |
| 277 | ; rdar://6283267 |
| 278 | define void @t17() nounwind ssp { |
| 279 | entry: |
| 280 | ; 32: t17: |
| 281 | ; 32: jmp {{_?}}bar5 |
| 282 | |
| 283 | ; 64: t17: |
| 284 | ; 64: xorb %al, %al |
| 285 | ; 64: jmp {{_?}}bar5 |
| 286 | tail call void (...)* @bar5() nounwind |
| 287 | ret void |
| 288 | } |
| 289 | |
| 290 | declare void @bar5(...) |
| 291 | |
| 292 | ; rdar://7774847 |
| 293 | define void @t18() nounwind ssp { |
| 294 | entry: |
| 295 | ; 32: t18: |
| 296 | ; 32: call {{_?}}bar6 |
| 297 | ; 32: fstp %st(0) |
| 298 | |
| 299 | ; 64: t18: |
| 300 | ; 64: xorb %al, %al |
| 301 | ; 64: jmp {{_?}}bar6 |
| 302 | %0 = tail call double (...)* @bar6() nounwind |
| 303 | ret void |
| 304 | } |
| 305 | |
| 306 | declare double @bar6(...) |
Evan Cheng | 2c12cb4 | 2010-03-26 16:26:03 +0000 | [diff] [blame] | 307 | |
| 308 | define void @t19() alignstack(32) nounwind { |
| 309 | entry: |
| 310 | ; CHECK: t19: |
| 311 | ; CHECK: andl $-32 |
| 312 | ; CHECK: call {{_?}}foo |
| 313 | tail call void @foo() nounwind |
| 314 | ret void |
| 315 | } |
| 316 | |
| 317 | declare void @foo() |
Evan Cheng | 1361796 | 2010-04-30 01:12:32 +0000 | [diff] [blame] | 318 | |
| 319 | ; If caller / callee calling convention mismatch then check if the return |
| 320 | ; values are returned in the same registers. |
| 321 | ; rdar://7874780 |
| 322 | |
| 323 | define double @t20(double %x) nounwind { |
| 324 | entry: |
| 325 | ; 32: t20: |
| 326 | ; 32: call {{_?}}foo20 |
| 327 | ; 32: fldl (%esp) |
| 328 | |
| 329 | ; 64: t20: |
| 330 | ; 64: jmp {{_?}}foo20 |
| 331 | %0 = tail call fastcc double @foo20(double %x) nounwind |
| 332 | ret double %0 |
| 333 | } |
| 334 | |
| 335 | declare fastcc double @foo20(double) nounwind |