1; RUN: llc -march x86 -mcpu pentium4 < %s | FileCheck %s -check-prefix=SSE 2; RUN: llc -march x86 -mcpu pentium3 < %s | FileCheck %s -check-prefix=NOSSE2 3; RUN: llc -march x86 -mcpu pentium2 < %s | FileCheck %s -check-prefix=NOSSE1 4; RUN: llc -march x86 -mcpu pentium < %s | FileCheck %s -check-prefix=NOCMOV 5; PR14035 6 7define double @test1(i32 %a, i32 %b, double %x) nounwind { 8 %cmp = icmp ugt i32 %a, %b 9 %sel = select i1 %cmp, double 99.0, double %x 10 ret double %sel 11 12; SSE-LABEL: test1: 13; SSE: movsd 14 15; NOSSE2-LABEL: test1: 16; NOSSE2: fcmovnbe 17 18; NOSSE1-LABEL: test1: 19; NOSSE1: fcmovnbe 20 21; NOCMOV-LABEL: test1: 22; NOCMOV: fstp 23 24} 25 26define double @test2(i32 %a, i32 %b, double %x) nounwind { 27 %cmp = icmp uge i32 %a, %b 28 %sel = select i1 %cmp, double 99.0, double %x 29 ret double %sel 30 31; SSE-LABEL: test2: 32; SSE: movsd 33 34; NOSSE2-LABEL: test2: 35; NOSSE2: fcmovnb 36 37; NOSSE1-LABEL: test2: 38; NOSSE1: fcmovnb 39 40; NOCMOV-LABEL: test2: 41; NOCMOV: fstp 42} 43 44define double @test3(i32 %a, i32 %b, double %x) nounwind { 45 %cmp = icmp ult i32 %a, %b 46 %sel = select i1 %cmp, double 99.0, double %x 47 ret double %sel 48 49; SSE-LABEL: test3: 50; SSE: movsd 51 52; NOSSE2-LABEL: test3: 53; NOSSE2: fcmovb 54 55; NOSSE1-LABEL: test3: 56; NOSSE1: fcmovb 57 58; NOCMOV-LABEL: test3: 59; NOCMOV: fstp 60} 61 62define double @test4(i32 %a, i32 %b, double %x) nounwind { 63 %cmp = icmp ule i32 %a, %b 64 %sel = select i1 %cmp, double 99.0, double %x 65 ret double %sel 66 67; SSE-LABEL: test4: 68; SSE: movsd 69 70; NOSSE2-LABEL: test4: 71; NOSSE2: fcmovbe 72 73; NOSSE1-LABEL: test4: 74; NOSSE1: fcmovbe 75 76; NOCMOV-LABEL: test4: 77; NOCMOV: fstp 78} 79 80define double @test5(i32 %a, i32 %b, double %x) nounwind { 81 %cmp = icmp sgt i32 %a, %b 82 %sel = select i1 %cmp, double 99.0, double %x 83 ret double %sel 84 85; SSE-LABEL: test5: 86; SSE: movsd 87 88; NOSSE2-LABEL: test5: 89; NOSSE2: fstp 90 91; NOSSE1-LABEL: test5: 92; NOSSE1: fstp 93 94; NOCMOV-LABEL: test5: 95; NOCMOV: fstp 96} 97 98define double @test6(i32 %a, i32 %b, double %x) nounwind { 99 %cmp = icmp sge i32 %a, %b 100 %sel = select i1 %cmp, double 99.0, double %x 101 ret double %sel 102 103; SSE-LABEL: test6: 104; SSE: movsd 105 106; NOSSE2-LABEL: test6: 107; NOSSE2: fstp 108 109; NOSSE1-LABEL: test6: 110; NOSSE1: fstp 111 112; NOCMOV-LABEL: test6: 113; NOCMOV: fstp 114} 115 116define double @test7(i32 %a, i32 %b, double %x) nounwind { 117 %cmp = icmp slt i32 %a, %b 118 %sel = select i1 %cmp, double 99.0, double %x 119 ret double %sel 120 121; SSE-LABEL: test7: 122; SSE: movsd 123 124; NOSSE2-LABEL: test7: 125; NOSSE2: fstp 126 127; NOSSE1-LABEL: test7: 128; NOSSE1: fstp 129 130; NOCMOV-LABEL: test7: 131; NOCMOV: fstp 132} 133 134define double @test8(i32 %a, i32 %b, double %x) nounwind { 135 %cmp = icmp sle i32 %a, %b 136 %sel = select i1 %cmp, double 99.0, double %x 137 ret double %sel 138 139; SSE-LABEL: test8: 140; SSE: movsd 141 142; NOSSE2-LABEL: test8: 143; NOSSE2: fstp 144 145; NOSSE1-LABEL: test8: 146; NOSSE1: fstp 147 148; NOCMOV-LABEL: test8: 149; NOCMOV: fstp 150} 151 152define float @test9(i32 %a, i32 %b, float %x) nounwind { 153 %cmp = icmp ugt i32 %a, %b 154 %sel = select i1 %cmp, float 99.0, float %x 155 ret float %sel 156 157; SSE-LABEL: test9: 158; SSE: movss 159 160; NOSSE2-LABEL: test9: 161; NOSSE2: movss 162 163; NOSSE1-LABEL: test9: 164; NOSSE1: fcmovnbe 165 166; NOCMOV-LABEL: test9: 167; NOCMOV: fstp 168} 169 170define float @test10(i32 %a, i32 %b, float %x) nounwind { 171 %cmp = icmp uge i32 %a, %b 172 %sel = select i1 %cmp, float 99.0, float %x 173 ret float %sel 174 175; SSE-LABEL: test10: 176; SSE: movss 177 178; NOSSE2-LABEL: test10: 179; NOSSE2: movss 180 181; NOSSE1-LABEL: test10: 182; NOSSE1: fcmovnb 183 184; NOCMOV-LABEL: test10: 185; NOCMOV: fstp 186} 187 188define float @test11(i32 %a, i32 %b, float %x) nounwind { 189 %cmp = icmp ult i32 %a, %b 190 %sel = select i1 %cmp, float 99.0, float %x 191 ret float %sel 192 193; SSE-LABEL: test11: 194; SSE: movss 195 196; NOSSE2-LABEL: test11: 197; NOSSE2: movss 198 199; NOSSE1-LABEL: test11: 200; NOSSE1: fcmovb 201 202; NOCMOV-LABEL: test11: 203; NOCMOV: fstp 204} 205 206define float @test12(i32 %a, i32 %b, float %x) nounwind { 207 %cmp = icmp ule i32 %a, %b 208 %sel = select i1 %cmp, float 99.0, float %x 209 ret float %sel 210 211; SSE-LABEL: test12: 212; SSE: movss 213 214; NOSSE2-LABEL: test12: 215; NOSSE2: movss 216 217; NOSSE1-LABEL: test12: 218; NOSSE1: fcmovbe 219 220; NOCMOV-LABEL: test12: 221; NOCMOV: fstp 222} 223 224define float @test13(i32 %a, i32 %b, float %x) nounwind { 225 %cmp = icmp sgt i32 %a, %b 226 %sel = select i1 %cmp, float 99.0, float %x 227 ret float %sel 228 229; SSE-LABEL: test13: 230; SSE: movss 231 232; NOSSE2-LABEL: test13: 233; NOSSE2: movss 234 235; NOSSE1-LABEL: test13: 236; NOSSE1: fstp 237 238; NOCMOV-LABEL: test13: 239; NOCMOV: fstp 240} 241 242define float @test14(i32 %a, i32 %b, float %x) nounwind { 243 %cmp = icmp sge i32 %a, %b 244 %sel = select i1 %cmp, float 99.0, float %x 245 ret float %sel 246 247; SSE-LABEL: test14: 248; SSE: movss 249 250; NOSSE2-LABEL: test14: 251; NOSSE2: movss 252 253; NOSSE1-LABEL: test14: 254; NOSSE1: fstp 255 256; NOCMOV-LABEL: test14: 257; NOCMOV: fstp 258} 259 260define float @test15(i32 %a, i32 %b, float %x) nounwind { 261 %cmp = icmp slt i32 %a, %b 262 %sel = select i1 %cmp, float 99.0, float %x 263 ret float %sel 264 265; SSE-LABEL: test15: 266; SSE: movss 267 268; NOSSE2-LABEL: test15: 269; NOSSE2: movss 270 271; NOSSE1-LABEL: test15: 272; NOSSE1: fstp 273 274; NOCMOV-LABEL: test15: 275; NOCMOV: fstp 276} 277 278define float @test16(i32 %a, i32 %b, float %x) nounwind { 279 %cmp = icmp sle i32 %a, %b 280 %sel = select i1 %cmp, float 99.0, float %x 281 ret float %sel 282 283; SSE-LABEL: test16: 284; SSE: movss 285 286; NOSSE2-LABEL: test16: 287; NOSSE2: movss 288 289; NOSSE1-LABEL: test16: 290; NOSSE1: fstp 291 292; NOCMOV-LABEL: test16: 293; NOCMOV: fstp 294} 295 296define x86_fp80 @test17(i32 %a, i32 %b, x86_fp80 %x) nounwind { 297 %cmp = icmp ugt i32 %a, %b 298 %sel = select i1 %cmp, x86_fp80 0xK4005C600000000000000, x86_fp80 %x 299 ret x86_fp80 %sel 300 301; SSE-LABEL: test17: 302; SSE: fcmovnbe 303 304; NOSSE2-LABEL: test17: 305; NOSSE2: fcmovnbe 306 307; NOSSE1-LABEL: test17: 308; NOSSE1: fcmovnbe 309 310; NOCMOV-LABEL: test17: 311; NOCMOV: fstp 312} 313 314define x86_fp80 @test18(i32 %a, i32 %b, x86_fp80 %x) nounwind { 315 %cmp = icmp uge i32 %a, %b 316 %sel = select i1 %cmp, x86_fp80 0xK4005C600000000000000, x86_fp80 %x 317 ret x86_fp80 %sel 318 319; SSE-LABEL: test18: 320; SSE: fcmovnb 321 322; NOSSE2-LABEL: test18: 323; NOSSE2: fcmovnb 324 325; NOSSE1-LABEL: test18: 326; NOSSE1: fcmovnb 327 328; NOCMOV-LABEL: test18: 329; NOCMOV: fstp 330} 331 332define x86_fp80 @test19(i32 %a, i32 %b, x86_fp80 %x) nounwind { 333 %cmp = icmp ult i32 %a, %b 334 %sel = select i1 %cmp, x86_fp80 0xK4005C600000000000000, x86_fp80 %x 335 ret x86_fp80 %sel 336 337; SSE-LABEL: test19: 338; SSE: fcmovb 339 340; NOSSE2-LABEL: test19: 341; NOSSE2: fcmovb 342 343; NOSSE1-LABEL: test19: 344; NOSSE1: fcmovb 345 346; NOCMOV-LABEL: test19: 347; NOCMOV: fstp 348} 349 350define x86_fp80 @test20(i32 %a, i32 %b, x86_fp80 %x) nounwind { 351 %cmp = icmp ule i32 %a, %b 352 %sel = select i1 %cmp, x86_fp80 0xK4005C600000000000000, x86_fp80 %x 353 ret x86_fp80 %sel 354 355; SSE-LABEL: test20: 356; SSE: fcmovbe 357 358; NOSSE2-LABEL: test20: 359; NOSSE2: fcmovbe 360 361; NOSSE1-LABEL: test20: 362; NOSSE1: fcmovbe 363 364; NOCMOV-LABEL: test20: 365; NOCMOV: fstp 366} 367 368define x86_fp80 @test21(i32 %a, i32 %b, x86_fp80 %x) nounwind { 369 %cmp = icmp sgt i32 %a, %b 370 %sel = select i1 %cmp, x86_fp80 0xK4005C600000000000000, x86_fp80 %x 371 ret x86_fp80 %sel 372 373; We don't emit a branch for fp80, why? 374; SSE-LABEL: test21: 375; SSE: testb 376; SSE: fcmovne 377 378; NOSSE2-LABEL: test21: 379; NOSSE2: testb 380; NOSSE2: fcmovne 381 382; NOSSE1-LABEL: test21: 383; NOSSE1: testb 384; NOSSE1: fcmovne 385 386; NOCMOV-LABEL: test21: 387; NOCMOV: fstp 388} 389 390define x86_fp80 @test22(i32 %a, i32 %b, x86_fp80 %x) nounwind { 391 %cmp = icmp sge i32 %a, %b 392 %sel = select i1 %cmp, x86_fp80 0xK4005C600000000000000, x86_fp80 %x 393 ret x86_fp80 %sel 394 395; SSE-LABEL: test22: 396; SSE: testb 397; SSE: fcmovne 398 399; NOSSE2-LABEL: test22: 400; NOSSE2: testb 401; NOSSE2: fcmovne 402 403; NOSSE1-LABEL: test22: 404; NOSSE1: testb 405; NOSSE1: fcmovne 406 407; NOCMOV-LABEL: test22: 408; NOCMOV: fstp 409} 410 411define x86_fp80 @test23(i32 %a, i32 %b, x86_fp80 %x) nounwind { 412 %cmp = icmp slt i32 %a, %b 413 %sel = select i1 %cmp, x86_fp80 0xK4005C600000000000000, x86_fp80 %x 414 ret x86_fp80 %sel 415 416; SSE-LABEL: test23: 417; SSE: testb 418; SSE: fcmovne 419 420; NOSSE2-LABEL: test23: 421; NOSSE2: testb 422; NOSSE2: fcmovne 423 424; NOSSE1-LABEL: test23: 425; NOSSE1: testb 426; NOSSE1: fcmovne 427 428; NOCMOV-LABEL: test23: 429; NOCMOV: fstp 430} 431 432define x86_fp80 @test24(i32 %a, i32 %b, x86_fp80 %x) nounwind { 433 %cmp = icmp sle i32 %a, %b 434 %sel = select i1 %cmp, x86_fp80 0xK4005C600000000000000, x86_fp80 %x 435 ret x86_fp80 %sel 436 437; SSE-LABEL: test24: 438; SSE: testb 439; SSE: fcmovne 440 441; NOSSE2-LABEL: test24: 442; NOSSE2: testb 443; NOSSE2: fcmovne 444 445; NOSSE1-LABEL: test24: 446; NOSSE1: testb 447; NOSSE1: fcmovne 448 449; NOCMOV-LABEL: test24: 450; NOCMOV: fstp 451} 452