1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -instsimplify -S | FileCheck %s 3 4declare <2 x double> @llvm.minnum.v2f64(<2 x double>, <2 x double>) 5declare <2 x double> @llvm.maxnum.v2f64(<2 x double>, <2 x double>) 6declare <2 x double> @llvm.minimum.v2f64(<2 x double>, <2 x double>) 7declare <2 x double> @llvm.maximum.v2f64(<2 x double>, <2 x double>) 8 9; Constant folding - undef undef. 10 11define double @fadd_undef_undef(double %x) { 12; CHECK-LABEL: @fadd_undef_undef( 13; CHECK-NEXT: ret double undef 14; 15 %r = fadd double undef, undef 16 ret double %r 17} 18 19define double @fsub_undef_undef(double %x) { 20; CHECK-LABEL: @fsub_undef_undef( 21; CHECK-NEXT: ret double undef 22; 23 %r = fsub double undef, undef 24 ret double %r 25} 26 27define double @fmul_undef_undef(double %x) { 28; CHECK-LABEL: @fmul_undef_undef( 29; CHECK-NEXT: ret double undef 30; 31 %r = fmul double undef, undef 32 ret double %r 33} 34 35define double @fdiv_undef_undef(double %x) { 36; CHECK-LABEL: @fdiv_undef_undef( 37; CHECK-NEXT: ret double undef 38; 39 %r = fdiv double undef, undef 40 ret double %r 41} 42 43define double @frem_undef_undef(double %x) { 44; CHECK-LABEL: @frem_undef_undef( 45; CHECK-NEXT: ret double undef 46; 47 %r = frem double undef, undef 48 ret double %r 49} 50 51; Constant folding. 52 53define float @fadd_undef_op0_nnan_constant(float %x) { 54; CHECK-LABEL: @fadd_undef_op0_nnan_constant( 55; CHECK-NEXT: ret float 0x7FF8000000000000 56; 57 %r = fadd nnan float undef, 1.0 58 ret float %r 59} 60 61define float @fadd_undef_op1_constant(float %x) { 62; CHECK-LABEL: @fadd_undef_op1_constant( 63; CHECK-NEXT: ret float 0x7FF8000000000000 64; 65 %r = fadd float 2.0, undef 66 ret float %r 67} 68 69define float @fsub_undef_op0_fast_constant(float %x) { 70; CHECK-LABEL: @fsub_undef_op0_fast_constant( 71; CHECK-NEXT: ret float 0x7FF8000000000000 72; 73 %r = fsub fast float undef, 3.0 74 ret float %r 75} 76 77define float @fsub_undef_op1_constant(float %x) { 78; CHECK-LABEL: @fsub_undef_op1_constant( 79; CHECK-NEXT: ret float 0x7FF8000000000000 80; 81 %r = fsub float 4.0, undef 82 ret float %r 83} 84 85define float @fmul_undef_op0_nnan_constant(float %x) { 86; CHECK-LABEL: @fmul_undef_op0_nnan_constant( 87; CHECK-NEXT: ret float 0x7FF8000000000000 88; 89 %r = fmul nnan float undef, 5.0 90 ret float %r 91} 92 93define float @fmul_undef_op1_constant(float %x) { 94; CHECK-LABEL: @fmul_undef_op1_constant( 95; CHECK-NEXT: ret float 0x7FF8000000000000 96; 97 %r = fmul float 6.0, undef 98 ret float %r 99} 100 101define float @fdiv_undef_op0_fast_constant(float %x) { 102; CHECK-LABEL: @fdiv_undef_op0_fast_constant( 103; CHECK-NEXT: ret float 0x7FF8000000000000 104; 105 %r = fdiv fast float undef, 7.0 106 ret float %r 107} 108 109define float @fdiv_undef_op1_constant(float %x) { 110; CHECK-LABEL: @fdiv_undef_op1_constant( 111; CHECK-NEXT: ret float 0x7FF8000000000000 112; 113 %r = fdiv float 8.0, undef 114 ret float %r 115} 116 117define float @frem_undef_op0_nnan_constant(float %x) { 118; CHECK-LABEL: @frem_undef_op0_nnan_constant( 119; CHECK-NEXT: ret float 0x7FF8000000000000 120; 121 %r = frem nnan float undef, 9.0 122 ret float %r 123} 124 125define float @frem_undef_op1_constant(float %x) { 126; CHECK-LABEL: @frem_undef_op1_constant( 127; CHECK-NEXT: ret float 0x7FF8000000000000 128; 129 %r = frem float 10.0, undef 130 ret float %r 131} 132 133; Constant folding - special constants: 0.0. 134 135define double @fadd_undef_op0_constant_0(double %x) { 136; CHECK-LABEL: @fadd_undef_op0_constant_0( 137; CHECK-NEXT: ret double 0x7FF8000000000000 138; 139 %r = fadd double undef, 0x0000000000000000 140 ret double %r 141} 142 143define double @fadd_undef_op1_constant_0(double %x) { 144; CHECK-LABEL: @fadd_undef_op1_constant_0( 145; CHECK-NEXT: ret double 0x7FF8000000000000 146; 147 %r = fadd double 0x0000000000000000, undef 148 ret double %r 149} 150 151define double @fsub_undef_op0_constant_0(double %x) { 152; CHECK-LABEL: @fsub_undef_op0_constant_0( 153; CHECK-NEXT: ret double 0x7FF8000000000000 154; 155 %r = fsub double undef, 0x0000000000000000 156 ret double %r 157} 158 159define double @fsub_undef_op1_constant_0(double %x) { 160; CHECK-LABEL: @fsub_undef_op1_constant_0( 161; CHECK-NEXT: ret double 0x7FF8000000000000 162; 163 %r = fsub double 0x0000000000000000, undef 164 ret double %r 165} 166 167define double @fmul_undef_op0_constant_0(double %x) { 168; CHECK-LABEL: @fmul_undef_op0_constant_0( 169; CHECK-NEXT: ret double 0x7FF8000000000000 170; 171 %r = fmul double undef, 0x0000000000000000 172 ret double %r 173} 174 175define double @fmul_undef_op1_constant_0(double %x) { 176; CHECK-LABEL: @fmul_undef_op1_constant_0( 177; CHECK-NEXT: ret double 0x7FF8000000000000 178; 179 %r = fmul double 0x0000000000000000, undef 180 ret double %r 181} 182 183define double @fdiv_undef_op0_constant_0(double %x) { 184; CHECK-LABEL: @fdiv_undef_op0_constant_0( 185; CHECK-NEXT: ret double 0x7FF8000000000000 186; 187 %r = fdiv double undef, 0x0000000000000000 188 ret double %r 189} 190 191define double @fdiv_undef_op1_constant_0(double %x) { 192; CHECK-LABEL: @fdiv_undef_op1_constant_0( 193; CHECK-NEXT: ret double 0x7FF8000000000000 194; 195 %r = fdiv double 0x0000000000000000, undef 196 ret double %r 197} 198 199define double @frem_undef_op0_constant_0(double %x) { 200; CHECK-LABEL: @frem_undef_op0_constant_0( 201; CHECK-NEXT: ret double 0x7FF8000000000000 202; 203 %r = frem double undef, 0x0000000000000000 204 ret double %r 205} 206 207define double @frem_undef_op1_constant_0(double %x) { 208; CHECK-LABEL: @frem_undef_op1_constant_0( 209; CHECK-NEXT: ret double 0x7FF8000000000000 210; 211 %r = frem double 0x0000000000000000, undef 212 ret double %r 213} 214 215; Constant folding - special constants: -0.0. 216 217define double @fadd_undef_op0_constant_neg0(double %x) { 218; CHECK-LABEL: @fadd_undef_op0_constant_neg0( 219; CHECK-NEXT: ret double undef 220; 221 %r = fadd double undef, 0x8000000000000000 222 ret double %r 223} 224 225define double @fadd_undef_op1_constant_neg0(double %x) { 226; CHECK-LABEL: @fadd_undef_op1_constant_neg0( 227; CHECK-NEXT: ret double undef 228; 229 %r = fadd double 0x8000000000000000, undef 230 ret double %r 231} 232 233define double @fsub_undef_op0_constant_neg0(double %x) { 234; CHECK-LABEL: @fsub_undef_op0_constant_neg0( 235; CHECK-NEXT: ret double 0x7FF8000000000000 236; 237 %r = fsub double undef, 0x8000000000000000 238 ret double %r 239} 240 241define double @fsub_undef_op1_constant_neg0(double %x) { 242; CHECK-LABEL: @fsub_undef_op1_constant_neg0( 243; CHECK-NEXT: ret double undef 244; 245 %r = fsub double 0x8000000000000000, undef 246 ret double %r 247} 248 249define double @fmul_undef_op0_constant_neg0(double %x) { 250; CHECK-LABEL: @fmul_undef_op0_constant_neg0( 251; CHECK-NEXT: ret double 0x7FF8000000000000 252; 253 %r = fmul double undef, 0x8000000000000000 254 ret double %r 255} 256 257define double @fmul_undef_op1_constant_neg0(double %x) { 258; CHECK-LABEL: @fmul_undef_op1_constant_neg0( 259; CHECK-NEXT: ret double 0x7FF8000000000000 260; 261 %r = fmul double 0x8000000000000000, undef 262 ret double %r 263} 264 265define double @fdiv_undef_op0_constant_neg0(double %x) { 266; CHECK-LABEL: @fdiv_undef_op0_constant_neg0( 267; CHECK-NEXT: ret double 0x7FF8000000000000 268; 269 %r = fdiv double undef, 0x8000000000000000 270 ret double %r 271} 272 273define double @fdiv_undef_op1_constant_neg0(double %x) { 274; CHECK-LABEL: @fdiv_undef_op1_constant_neg0( 275; CHECK-NEXT: ret double 0x7FF8000000000000 276; 277 %r = fdiv double 0x8000000000000000, undef 278 ret double %r 279} 280 281define double @frem_undef_op0_constant_neg0(double %x) { 282; CHECK-LABEL: @frem_undef_op0_constant_neg0( 283; CHECK-NEXT: ret double 0x7FF8000000000000 284; 285 %r = frem double undef, 0x8000000000000000 286 ret double %r 287} 288 289define double @frem_undef_op1_constant_neg0(double %x) { 290; CHECK-LABEL: @frem_undef_op1_constant_neg0( 291; CHECK-NEXT: ret double 0x7FF8000000000000 292; 293 %r = frem double 0x8000000000000000, undef 294 ret double %r 295} 296 297; Constant folding - special constants: NaN. 298 299define double @fadd_undef_op0_constant_nan(double %x) { 300; CHECK-LABEL: @fadd_undef_op0_constant_nan( 301; CHECK-NEXT: ret double 0x7FF8000000000000 302; 303 %r = fadd double undef, 0x7FF8000000000000 304 ret double %r 305} 306 307define double @fadd_undef_op1_fast_constant_nan(double %x) { 308; CHECK-LABEL: @fadd_undef_op1_fast_constant_nan( 309; CHECK-NEXT: ret double 0x7FF8000000000000 310; 311 %r = fadd fast double 0xFFF0000000000001, undef 312 ret double %r 313} 314 315define double @fsub_undef_op0_constant_nan(double %x) { 316; CHECK-LABEL: @fsub_undef_op0_constant_nan( 317; CHECK-NEXT: ret double 0x7FF8000000000000 318; 319 %r = fsub double undef, 0xFFF8000000000010 320 ret double %r 321} 322 323define double @fsub_undef_op1_nnan_constant_nan(double %x) { 324; CHECK-LABEL: @fsub_undef_op1_nnan_constant_nan( 325; CHECK-NEXT: ret double 0x7FF8000000000000 326; 327 %r = fsub nnan double 0x7FF0000000000011, undef 328 ret double %r 329} 330 331define double @fmul_undef_op0_constant_nan(double %x) { 332; CHECK-LABEL: @fmul_undef_op0_constant_nan( 333; CHECK-NEXT: ret double 0x7FF8000000000000 334; 335 %r = fmul double undef, 0x7FF8000000000100 336 ret double %r 337} 338 339define double @fmul_undef_op1_fast_constant_nan(double %x) { 340; CHECK-LABEL: @fmul_undef_op1_fast_constant_nan( 341; CHECK-NEXT: ret double 0x7FF8000000000000 342; 343 %r = fmul fast double 0xFFF0000000000101, undef 344 ret double %r 345} 346 347define double @fdiv_undef_op0_constant_nan(double %x) { 348; CHECK-LABEL: @fdiv_undef_op0_constant_nan( 349; CHECK-NEXT: ret double 0x7FF8000000000000 350; 351 %r = fdiv double undef, 0xFFF8000000000110 352 ret double %r 353} 354 355define double @fdiv_undef_op1_nnan_constant_nan(double %x) { 356; CHECK-LABEL: @fdiv_undef_op1_nnan_constant_nan( 357; CHECK-NEXT: ret double 0x7FF8000000000000 358; 359 %r = fdiv nnan double 0x7FF0000000000111, undef 360 ret double %r 361} 362 363define double @frem_undef_op0_constant_nan(double %x) { 364; CHECK-LABEL: @frem_undef_op0_constant_nan( 365; CHECK-NEXT: ret double 0x7FF8000000000000 366; 367 %r = frem double undef, 0x7FF8000000001000 368 ret double %r 369} 370 371define double @frem_undef_op1_fast_constant_nan(double %x) { 372; CHECK-LABEL: @frem_undef_op1_fast_constant_nan( 373; CHECK-NEXT: ret double 0x7FF8000000000000 374; 375 %r = frem fast double 0xFFF0000000001001, undef 376 ret double %r 377} 378 379; Constant folding - special constants: Inf. 380 381define double @fadd_undef_op0_constant_inf(double %x) { 382; CHECK-LABEL: @fadd_undef_op0_constant_inf( 383; CHECK-NEXT: ret double 0x7FF8000000000000 384; 385 %r = fadd double undef, 0x7FF0000000000000 386 ret double %r 387} 388 389define double @fadd_undef_op1_fast_constant_inf(double %x) { 390; CHECK-LABEL: @fadd_undef_op1_fast_constant_inf( 391; CHECK-NEXT: ret double 0x7FF8000000000000 392; 393 %r = fadd fast double 0xFFF0000000000000, undef 394 ret double %r 395} 396 397define double @fsub_undef_op0_constant_inf(double %x) { 398; CHECK-LABEL: @fsub_undef_op0_constant_inf( 399; CHECK-NEXT: ret double 0x7FF8000000000000 400; 401 %r = fsub double undef, 0xFFF0000000000000 402 ret double %r 403} 404 405define double @fsub_undef_op1_ninf_constant_inf(double %x) { 406; CHECK-LABEL: @fsub_undef_op1_ninf_constant_inf( 407; CHECK-NEXT: ret double 0x7FF8000000000000 408; 409 %r = fsub ninf double 0x7FF0000000000000, undef 410 ret double %r 411} 412 413define double @fmul_undef_op0_constant_inf(double %x) { 414; CHECK-LABEL: @fmul_undef_op0_constant_inf( 415; CHECK-NEXT: ret double 0x7FF8000000000000 416; 417 %r = fmul double undef, 0x7FF0000000000000 418 ret double %r 419} 420 421define double @fmul_undef_op1_fast_constant_inf(double %x) { 422; CHECK-LABEL: @fmul_undef_op1_fast_constant_inf( 423; CHECK-NEXT: ret double 0x7FF8000000000000 424; 425 %r = fmul fast double 0xFFF0000000000000, undef 426 ret double %r 427} 428 429define double @fdiv_undef_op0_constant_inf(double %x) { 430; CHECK-LABEL: @fdiv_undef_op0_constant_inf( 431; CHECK-NEXT: ret double 0x7FF8000000000000 432; 433 %r = fdiv double undef, 0xFFF0000000000000 434 ret double %r 435} 436 437define double @fdiv_undef_op1_ninf_constant_inf(double %x) { 438; CHECK-LABEL: @fdiv_undef_op1_ninf_constant_inf( 439; CHECK-NEXT: ret double 0x7FF8000000000000 440; 441 %r = fdiv ninf double 0x7FF0000000000000, undef 442 ret double %r 443} 444 445define double @frem_undef_op0_constant_inf(double %x) { 446; CHECK-LABEL: @frem_undef_op0_constant_inf( 447; CHECK-NEXT: ret double 0x7FF8000000000000 448; 449 %r = frem double undef, 0x7FF0000000000000 450 ret double %r 451} 452 453define double @frem_undef_op1_fast_constant_inf(double %x) { 454; CHECK-LABEL: @frem_undef_op1_fast_constant_inf( 455; CHECK-NEXT: ret double 0x7FF8000000000000 456; 457 %r = frem fast double 0xFFF0000000000000, undef 458 ret double %r 459} 460 461define <2 x double> @fadd_undef_op1_constant_vec(<2 x double> %x) { 462; CHECK-LABEL: @fadd_undef_op1_constant_vec( 463; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef> 464; 465 %r = fadd <2 x double> <double 42.0, double undef>, undef 466 ret <2 x double> %r 467} 468 469define <2 x double> @fadd_undef_op0_constant_vec(<2 x double> %x) { 470; CHECK-LABEL: @fadd_undef_op0_constant_vec( 471; CHECK-NEXT: ret <2 x double> <double undef, double 0x7FF8000000000000> 472; 473 %r = fadd <2 x double> undef, <double undef, double 42.0> 474 ret <2 x double> %r 475} 476 477define <2 x double> @fsub_undef_op1_constant_vec(<2 x double> %x) { 478; CHECK-LABEL: @fsub_undef_op1_constant_vec( 479; CHECK-NEXT: ret <2 x double> <double undef, double 0x7FF8000000000000> 480; 481 %r = fsub <2 x double> <double undef, double 42.0>, undef 482 ret <2 x double> %r 483} 484 485define <2 x double> @fsub_undef_op0_constant_vec(<2 x double> %x) { 486; CHECK-LABEL: @fsub_undef_op0_constant_vec( 487; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef> 488; 489 %r = fsub <2 x double> undef, <double 42.0, double undef> 490 ret <2 x double> %r 491} 492 493define <2 x double> @fmul_undef_op1_constant_vec(<2 x double> %x) { 494; CHECK-LABEL: @fmul_undef_op1_constant_vec( 495; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef> 496; 497 %r = fmul <2 x double> <double 42.0, double undef>, undef 498 ret <2 x double> %r 499} 500 501define <2 x double> @fmul_undef_op0_constant_vec(<2 x double> %x) { 502; CHECK-LABEL: @fmul_undef_op0_constant_vec( 503; CHECK-NEXT: ret <2 x double> <double undef, double 0x7FF8000000000000> 504; 505 %r = fmul <2 x double> undef, <double undef, double 42.0> 506 ret <2 x double> %r 507} 508 509define <2 x double> @fdiv_undef_op1_constant_vec(<2 x double> %x) { 510; CHECK-LABEL: @fdiv_undef_op1_constant_vec( 511; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef> 512; 513 %r = fdiv <2 x double> <double 42.0, double undef>, undef 514 ret <2 x double> %r 515} 516 517define <2 x double> @fdiv_undef_op0_constant_vec(<2 x double> %x) { 518; CHECK-LABEL: @fdiv_undef_op0_constant_vec( 519; CHECK-NEXT: ret <2 x double> <double undef, double 0x7FF8000000000000> 520; 521 %r = fdiv <2 x double> undef, <double undef, double 42.0> 522 ret <2 x double> %r 523} 524 525define <2 x double> @frem_undef_op1_constant_vec(<2 x double> %x) { 526; CHECK-LABEL: @frem_undef_op1_constant_vec( 527; CHECK-NEXT: ret <2 x double> <double undef, double 0x7FF8000000000000> 528; 529 %r = frem <2 x double> <double undef, double 42.0>, undef 530 ret <2 x double> %r 531} 532 533define <2 x double> @frem_undef_op0_constant_vec(<2 x double> %x) { 534; CHECK-LABEL: @frem_undef_op0_constant_vec( 535; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef> 536; 537 %r = frem <2 x double> undef, <double 42.0, double undef> 538 ret <2 x double> %r 539} 540 541define <2 x double> @maximum_nan_op0_vec_partial_undef_op1_undef(<2 x double> %x) { 542; CHECK-LABEL: @maximum_nan_op0_vec_partial_undef_op1_undef( 543; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef> 544; 545 %r = call <2 x double> @llvm.maximum.v2f64(<2 x double> <double 0x7ff8000000000000, double undef>, <2 x double> undef) 546 ret <2 x double> %r 547} 548 549define <2 x double> @maximum_nan_op1_vec_partial_undef_op0_undef(<2 x double> %x) { 550; CHECK-LABEL: @maximum_nan_op1_vec_partial_undef_op0_undef( 551; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef> 552; 553 %r = call <2 x double> @llvm.maximum.v2f64(<2 x double> undef, <2 x double> <double 0x7ff8000000000000, double undef>) 554 ret <2 x double> %r 555} 556 557define <2 x double> @minimum_nan_op0_vec_partial_undef_op1_undef(<2 x double> %x) { 558; CHECK-LABEL: @minimum_nan_op0_vec_partial_undef_op1_undef( 559; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef> 560; 561 %r = call <2 x double> @llvm.minimum.v2f64(<2 x double> <double 0x7ff8000000000000, double undef>, <2 x double> undef) 562 ret <2 x double> %r 563} 564 565define <2 x double> @minimum_nan_op1_vec_partial_undef_op0_undef(<2 x double> %x) { 566; CHECK-LABEL: @minimum_nan_op1_vec_partial_undef_op0_undef( 567; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef> 568; 569 %r = call <2 x double> @llvm.minimum.v2f64(<2 x double> undef, <2 x double> <double 0x7ff8000000000000, double undef>) 570 ret <2 x double> %r 571} 572 573define <2 x double> @maxnum_nan_op0_vec_partial_undef_op1_undef(<2 x double> %x) { 574; CHECK-LABEL: @maxnum_nan_op0_vec_partial_undef_op1_undef( 575; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef> 576; 577 %r = call <2 x double> @llvm.maxnum.v2f64(<2 x double> <double 0x7ff8000000000000, double undef>, <2 x double> undef) 578 ret <2 x double> %r 579} 580 581define <2 x double> @maxnum_nan_op1_vec_partial_undef_op0_undef(<2 x double> %x) { 582; CHECK-LABEL: @maxnum_nan_op1_vec_partial_undef_op0_undef( 583; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef> 584; 585 %r = call <2 x double> @llvm.maxnum.v2f64(<2 x double> undef, <2 x double> <double 0x7ff8000000000000, double undef>) 586 ret <2 x double> %r 587} 588 589define <2 x double> @minnum_nan_op0_vec_partial_undef_op1_undef(<2 x double> %x) { 590; CHECK-LABEL: @minnum_nan_op0_vec_partial_undef_op1_undef( 591; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef> 592; 593 %r = call <2 x double> @llvm.minnum.v2f64(<2 x double> <double 0x7ff8000000000000, double undef>, <2 x double> undef) 594 ret <2 x double> %r 595} 596 597define <2 x double> @minnum_nan_op1_vec_partial_undef_op0_undef(<2 x double> %x) { 598; CHECK-LABEL: @minnum_nan_op1_vec_partial_undef_op0_undef( 599; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double undef> 600; 601 %r = call <2 x double> @llvm.minnum.v2f64(<2 x double> undef, <2 x double> <double 0x7ff8000000000000, double undef>) 602 ret <2 x double> %r 603} 604