1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2 ; RUN: llc < %s -mtriple=i386-apple-darwin10 -mcpu=penryn | FileCheck %s 3 4 ; rdar://7475489 5 6 define i32 @test1(i32 %a, i32 %b) nounwind ssp { 7 ; CHECK-LABEL: test1: 8 ; CHECK: ## %bb.0: ## %entry 9 ; CHECK-NEXT: movb {{[0-9]+}}(%esp), %al 10 ; CHECK-NEXT: xorb {{[0-9]+}}(%esp), %al 11 ; CHECK-NEXT: testb $64, %al 12 ; CHECK-NEXT: je LBB0_1 13 ; CHECK-NEXT: ## %bb.2: ## %bb1 14 ; CHECK-NEXT: jmp _bar ## TAILCALL 15 ; CHECK-NEXT: LBB0_1: ## %bb 16 ; CHECK-NEXT: jmp _foo ## TAILCALL 17 entry: 18 %0 = and i32 %a, 16384 19 %1 = icmp ne i32 %0, 0 20 %2 = and i32 %b, 16384 21 %3 = icmp ne i32 %2, 0 22 %4 = xor i1 %1, %3 23 br i1 %4, label %bb1, label %bb 24 25 bb: ; preds = %entry 26 %5 = tail call i32 (...) @foo() nounwind ; <i32> [#uses=1] 27 ret i32 %5 28 29 bb1: ; preds = %entry 30 %6 = tail call i32 (...) @bar() nounwind ; <i32> [#uses=1] 31 ret i32 %6 32 } 33 34 declare i32 @foo(...) 35 36 declare i32 @bar(...) 37 38 39 ; <rdar://problem/7598384>: 40 ; 41 ; jCC L1 42 ; jmp L2 43 ; L1: 44 ; ... 45 ; L2: 46 ; ... 47 ; 48 ; to: 49 ; 50 ; jnCC L2 51 ; L1: 52 ; ... 53 ; L2: 54 ; ... 55 define float @test4(float %x, float %y) nounwind readnone optsize ssp { 56 ; CHECK-LABEL: test4: 57 ; CHECK: ## %bb.0: ## %entry 58 ; CHECK-NEXT: pushl %eax 59 ; CHECK-NEXT: cvtss2sd {{[0-9]+}}(%esp), %xmm1 60 ; CHECK-NEXT: cvtss2sd {{[0-9]+}}(%esp), %xmm0 61 ; CHECK-NEXT: mulsd %xmm1, %xmm0 62 ; CHECK-NEXT: xorpd %xmm1, %xmm1 63 ; CHECK-NEXT: ucomisd %xmm1, %xmm0 64 ; CHECK-NEXT: jne LBB1_1 65 ; CHECK-NEXT: jnp LBB1_2 66 ; CHECK-NEXT: LBB1_1: ## %bb1 67 ; CHECK-NEXT: addsd LCPI1_0, %xmm0 68 ; CHECK-NEXT: LBB1_2: ## %bb2 69 ; CHECK-NEXT: cvtsd2ss %xmm0, %xmm0 70 ; CHECK-NEXT: movss %xmm0, (%esp) 71 ; CHECK-NEXT: flds (%esp) 72 ; CHECK-NEXT: popl %eax 73 ; CHECK-NEXT: retl 74 entry: 75 %0 = fpext float %x to double ; <double> [#uses=1] 76 %1 = fpext float %y to double ; <double> [#uses=1] 77 %2 = fmul double %0, %1 ; <double> [#uses=3] 78 %3 = fcmp oeq double %2, 0.000000e+00 ; <i1> [#uses=1] 79 br i1 %3, label %bb2, label %bb1 80 81 82 bb1: ; preds = %entry 83 %4 = fadd double %2, -1.000000e+00 ; <double> [#uses=1] 84 br label %bb2 85 86 bb2: ; preds = %entry, %bb1 87 %.0.in = phi double [ %4, %bb1 ], [ %2, %entry ] ; <double> [#uses=1] 88 %.0 = fptrunc double %.0.in to float ; <float> [#uses=1] 89 ret float %.0 90 } 91 92 declare i32 @llvm.x86.sse41.ptestz(<4 x float> %p1, <4 x float> %p2) nounwind 93 declare i32 @llvm.x86.sse41.ptestc(<4 x float> %p1, <4 x float> %p2) nounwind 94 95 define <4 x float> @test5(<4 x float> %a, <4 x float> %b) nounwind { 96 ; CHECK-LABEL: test5: 97 ; CHECK: ## %bb.0: ## %entry 98 ; CHECK-NEXT: ptest %xmm0, %xmm0 99 ; CHECK-NEXT: jne LBB2_2 100 ; CHECK-NEXT: ## %bb.1: ## %bb1 101 ; CHECK-NEXT: addps LCPI2_0, %xmm1 102 ; CHECK-NEXT: movaps %xmm1, %xmm0 103 ; CHECK-NEXT: retl 104 ; CHECK-NEXT: LBB2_2: ## %bb2 105 ; CHECK-NEXT: divps LCPI2_0, %xmm1 106 ; CHECK-NEXT: movaps %xmm1, %xmm0 107 ; CHECK-NEXT: retl 108 entry: 109 110 %res = call i32 @llvm.x86.sse41.ptestz(<4 x float> %a, <4 x float> %a) nounwind 111 %one = icmp ne i32 %res, 0 112 br i1 %one, label %bb1, label %bb2 113 114 bb1: 115 %c = fadd <4 x float> %b, < float 1.000000e+002, float 2.000000e+002, float 3.000000e+002, float 4.000000e+002 > 116 br label %return 117 118 bb2: 119 %d = fdiv <4 x float> %b, < float 1.000000e+002, float 2.000000e+002, float 3.000000e+002, float 4.000000e+002 > 120 br label %return 121 122 return: 123 %e = phi <4 x float> [%c, %bb1], [%d, %bb2] 124 ret <4 x float> %e 125 } 126 127 define <4 x float> @test7(<4 x float> %a, <4 x float> %b) nounwind { 128 ; CHECK-LABEL: test7: 129 ; CHECK: ## %bb.0: ## %entry 130 ; CHECK-NEXT: ptest %xmm0, %xmm0 131 ; CHECK-NEXT: jne LBB3_2 132 ; CHECK-NEXT: ## %bb.1: ## %bb1 133 ; CHECK-NEXT: addps LCPI3_0, %xmm1 134 ; CHECK-NEXT: movaps %xmm1, %xmm0 135 ; CHECK-NEXT: retl 136 ; CHECK-NEXT: LBB3_2: ## %bb2 137 ; CHECK-NEXT: divps LCPI3_0, %xmm1 138 ; CHECK-NEXT: movaps %xmm1, %xmm0 139 ; CHECK-NEXT: retl 140 entry: 141 142 %res = call i32 @llvm.x86.sse41.ptestz(<4 x float> %a, <4 x float> %a) nounwind 143 %one = trunc i32 %res to i1 144 br i1 %one, label %bb1, label %bb2 145 146 bb1: 147 %c = fadd <4 x float> %b, < float 1.000000e+002, float 2.000000e+002, float 3.000000e+002, float 4.000000e+002 > 148 br label %return 149 150 bb2: 151 %d = fdiv <4 x float> %b, < float 1.000000e+002, float 2.000000e+002, float 3.000000e+002, float 4.000000e+002 > 152 br label %return 153 154 return: 155 %e = phi <4 x float> [%c, %bb1], [%d, %bb2] 156 ret <4 x float> %e 157 } 158 159 define <4 x float> @test8(<4 x float> %a, <4 x float> %b) nounwind { 160 ; CHECK-LABEL: test8: 161 ; CHECK: ## %bb.0: ## %entry 162 ; CHECK-NEXT: ptest %xmm0, %xmm0 163 ; CHECK-NEXT: jae LBB4_2 164 ; CHECK-NEXT: ## %bb.1: ## %bb1 165 ; CHECK-NEXT: addps LCPI4_0, %xmm1 166 ; CHECK-NEXT: movaps %xmm1, %xmm0 167 ; CHECK-NEXT: retl 168 ; CHECK-NEXT: LBB4_2: ## %bb2 169 ; CHECK-NEXT: divps LCPI4_0, %xmm1 170 ; CHECK-NEXT: movaps %xmm1, %xmm0 171 ; CHECK-NEXT: retl 172 entry: 173 174 %res = call i32 @llvm.x86.sse41.ptestc(<4 x float> %a, <4 x float> %a) nounwind 175 %one = icmp ne i32 %res, 0 176 br i1 %one, label %bb1, label %bb2 177 178 bb1: 179 %c = fadd <4 x float> %b, < float 1.000000e+002, float 2.000000e+002, float 3.000000e+002, float 4.000000e+002 > 180 br label %return 181 182 bb2: 183 %d = fdiv <4 x float> %b, < float 1.000000e+002, float 2.000000e+002, float 3.000000e+002, float 4.000000e+002 > 184 br label %return 185 186 return: 187 %e = phi <4 x float> [%c, %bb1], [%d, %bb2] 188 ret <4 x float> %e 189 } 190 191 define <4 x float> @test10(<4 x float> %a, <4 x float> %b) nounwind { 192 ; CHECK-LABEL: test10: 193 ; CHECK: ## %bb.0: ## %entry 194 ; CHECK-NEXT: ptest %xmm0, %xmm0 195 ; CHECK-NEXT: jae LBB5_2 196 ; CHECK-NEXT: ## %bb.1: ## %bb1 197 ; CHECK-NEXT: addps LCPI5_0, %xmm1 198 ; CHECK-NEXT: movaps %xmm1, %xmm0 199 ; CHECK-NEXT: retl 200 ; CHECK-NEXT: LBB5_2: ## %bb2 201 ; CHECK-NEXT: divps LCPI5_0, %xmm1 202 ; CHECK-NEXT: movaps %xmm1, %xmm0 203 ; CHECK-NEXT: retl 204 entry: 205 206 %res = call i32 @llvm.x86.sse41.ptestc(<4 x float> %a, <4 x float> %a) nounwind 207 %one = trunc i32 %res to i1 208 br i1 %one, label %bb1, label %bb2 209 210 bb1: 211 %c = fadd <4 x float> %b, < float 1.000000e+002, float 2.000000e+002, float 3.000000e+002, float 4.000000e+002 > 212 br label %return 213 214 bb2: 215 %d = fdiv <4 x float> %b, < float 1.000000e+002, float 2.000000e+002, float 3.000000e+002, float 4.000000e+002 > 216 br label %return 217 218 return: 219 %e = phi <4 x float> [%c, %bb1], [%d, %bb2] 220 ret <4 x float> %e 221 } 222 223 define <4 x float> @test11(<4 x float> %a, <4 x float> %b) nounwind { 224 ; CHECK-LABEL: test11: 225 ; CHECK: ## %bb.0: ## %entry 226 ; CHECK-NEXT: ptest %xmm0, %xmm0 227 ; CHECK-NEXT: jne LBB6_2 228 ; CHECK-NEXT: ## %bb.1: ## %bb1 229 ; CHECK-NEXT: addps LCPI6_0, %xmm1 230 ; CHECK-NEXT: movaps %xmm1, %xmm0 231 ; CHECK-NEXT: retl 232 ; CHECK-NEXT: LBB6_2: ## %bb2 233 ; CHECK-NEXT: divps LCPI6_0, %xmm1 234 ; CHECK-NEXT: movaps %xmm1, %xmm0 235 ; CHECK-NEXT: retl 236 entry: 237 238 %res = call i32 @llvm.x86.sse41.ptestz(<4 x float> %a, <4 x float> %a) nounwind 239 %one = icmp eq i32 %res, 1 240 br i1 %one, label %bb1, label %bb2 241 242 bb1: 243 %c = fadd <4 x float> %b, < float 1.000000e+002, float 2.000000e+002, float 3.000000e+002, float 4.000000e+002 > 244 br label %return 245 246 bb2: 247 %d = fdiv <4 x float> %b, < float 1.000000e+002, float 2.000000e+002, float 3.000000e+002, float 4.000000e+002 > 248 br label %return 249 250 return: 251 %e = phi <4 x float> [%c, %bb1], [%d, %bb2] 252 ret <4 x float> %e 253 } 254 255 define <4 x float> @test12(<4 x float> %a, <4 x float> %b) nounwind { 256 ; CHECK-LABEL: test12: 257 ; CHECK: ## %bb.0: ## %entry 258 ; CHECK-NEXT: ptest %xmm0, %xmm0 259 ; CHECK-NEXT: je LBB7_2 260 ; CHECK-NEXT: ## %bb.1: ## %bb1 261 ; CHECK-NEXT: addps LCPI7_0, %xmm1 262 ; CHECK-NEXT: movaps %xmm1, %xmm0 263 ; CHECK-NEXT: retl 264 ; CHECK-NEXT: LBB7_2: ## %bb2 265 ; CHECK-NEXT: divps LCPI7_0, %xmm1 266 ; CHECK-NEXT: movaps %xmm1, %xmm0 267 ; CHECK-NEXT: retl 268 entry: 269 270 %res = call i32 @llvm.x86.sse41.ptestz(<4 x float> %a, <4 x float> %a) nounwind 271 %one = icmp ne i32 %res, 1 272 br i1 %one, label %bb1, label %bb2 273 274 bb1: 275 %c = fadd <4 x float> %b, < float 1.000000e+002, float 2.000000e+002, float 3.000000e+002, float 4.000000e+002 > 276 br label %return 277 278 bb2: 279 %d = fdiv <4 x float> %b, < float 1.000000e+002, float 2.000000e+002, float 3.000000e+002, float 4.000000e+002 > 280 br label %return 281 282 return: 283 %e = phi <4 x float> [%c, %bb1], [%d, %bb2] 284 ret <4 x float> %e 285 } 286 287