1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc < %s -mtriple=i686-unknown | FileCheck %s --check-prefix=X86 3; RUN: llc < %s -mtriple=x86_64-unknown | FileCheck %s --check-prefix=X64 4 5define i16 @test_mul_by_1(i16 %x) { 6; X86-LABEL: test_mul_by_1: 7; X86: # %bb.0: 8; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax 9; X86-NEXT: retl 10; 11; X64-LABEL: test_mul_by_1: 12; X64: # %bb.0: 13; X64-NEXT: movl %edi, %eax 14; X64-NEXT: retq 15 %mul = mul nsw i16 %x, 1 16 ret i16 %mul 17} 18 19define i16 @test_mul_by_2(i16 %x) { 20; X86-LABEL: test_mul_by_2: 21; X86: # %bb.0: 22; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 23; X86-NEXT: addl %eax, %eax 24; X86-NEXT: # kill: def $ax killed $ax killed $eax 25; X86-NEXT: retl 26; 27; X64-LABEL: test_mul_by_2: 28; X64: # %bb.0: 29; X64-NEXT: # kill: def $edi killed $edi def $rdi 30; X64-NEXT: leal (%rdi,%rdi), %eax 31; X64-NEXT: # kill: def $ax killed $ax killed $eax 32; X64-NEXT: retq 33 %mul = mul nsw i16 %x, 2 34 ret i16 %mul 35} 36 37define i16 @test_mul_by_3(i16 %x) { 38; X86-LABEL: test_mul_by_3: 39; X86: # %bb.0: 40; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 41; X86-NEXT: leal (%eax,%eax,2), %eax 42; X86-NEXT: # kill: def $ax killed $ax killed $eax 43; X86-NEXT: retl 44; 45; X64-LABEL: test_mul_by_3: 46; X64: # %bb.0: 47; X64-NEXT: # kill: def $edi killed $edi def $rdi 48; X64-NEXT: leal (%rdi,%rdi,2), %eax 49; X64-NEXT: # kill: def $ax killed $ax killed $eax 50; X64-NEXT: retq 51 %mul = mul nsw i16 %x, 3 52 ret i16 %mul 53} 54 55define i16 @test_mul_by_4(i16 %x) { 56; X86-LABEL: test_mul_by_4: 57; X86: # %bb.0: 58; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 59; X86-NEXT: shll $2, %eax 60; X86-NEXT: # kill: def $ax killed $ax killed $eax 61; X86-NEXT: retl 62; 63; X64-LABEL: test_mul_by_4: 64; X64: # %bb.0: 65; X64-NEXT: # kill: def $edi killed $edi def $rdi 66; X64-NEXT: leal (,%rdi,4), %eax 67; X64-NEXT: # kill: def $ax killed $ax killed $eax 68; X64-NEXT: retq 69 %mul = mul nsw i16 %x, 4 70 ret i16 %mul 71} 72 73define i16 @test_mul_by_5(i16 %x) { 74; X86-LABEL: test_mul_by_5: 75; X86: # %bb.0: 76; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 77; X86-NEXT: leal (%eax,%eax,4), %eax 78; X86-NEXT: # kill: def $ax killed $ax killed $eax 79; X86-NEXT: retl 80; 81; X64-LABEL: test_mul_by_5: 82; X64: # %bb.0: 83; X64-NEXT: # kill: def $edi killed $edi def $rdi 84; X64-NEXT: leal (%rdi,%rdi,4), %eax 85; X64-NEXT: # kill: def $ax killed $ax killed $eax 86; X64-NEXT: retq 87 %mul = mul nsw i16 %x, 5 88 ret i16 %mul 89} 90 91define i16 @test_mul_by_6(i16 %x) { 92; X86-LABEL: test_mul_by_6: 93; X86: # %bb.0: 94; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 95; X86-NEXT: addl %eax, %eax 96; X86-NEXT: leal (%eax,%eax,2), %eax 97; X86-NEXT: # kill: def $ax killed $ax killed $eax 98; X86-NEXT: retl 99; 100; X64-LABEL: test_mul_by_6: 101; X64: # %bb.0: 102; X64-NEXT: # kill: def $edi killed $edi def $rdi 103; X64-NEXT: addl %edi, %edi 104; X64-NEXT: leal (%rdi,%rdi,2), %eax 105; X64-NEXT: # kill: def $ax killed $ax killed $eax 106; X64-NEXT: retq 107 %mul = mul nsw i16 %x, 6 108 ret i16 %mul 109} 110 111define i16 @test_mul_by_7(i16 %x) { 112; X86-LABEL: test_mul_by_7: 113; X86: # %bb.0: 114; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 115; X86-NEXT: leal (,%ecx,8), %eax 116; X86-NEXT: subl %ecx, %eax 117; X86-NEXT: # kill: def $ax killed $ax killed $eax 118; X86-NEXT: retl 119; 120; X64-LABEL: test_mul_by_7: 121; X64: # %bb.0: 122; X64-NEXT: # kill: def $edi killed $edi def $rdi 123; X64-NEXT: leal (,%rdi,8), %eax 124; X64-NEXT: subl %edi, %eax 125; X64-NEXT: # kill: def $ax killed $ax killed $eax 126; X64-NEXT: retq 127 %mul = mul nsw i16 %x, 7 128 ret i16 %mul 129} 130 131define i16 @test_mul_by_8(i16 %x) { 132; X86-LABEL: test_mul_by_8: 133; X86: # %bb.0: 134; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 135; X86-NEXT: shll $3, %eax 136; X86-NEXT: # kill: def $ax killed $ax killed $eax 137; X86-NEXT: retl 138; 139; X64-LABEL: test_mul_by_8: 140; X64: # %bb.0: 141; X64-NEXT: # kill: def $edi killed $edi def $rdi 142; X64-NEXT: leal (,%rdi,8), %eax 143; X64-NEXT: # kill: def $ax killed $ax killed $eax 144; X64-NEXT: retq 145 %mul = mul nsw i16 %x, 8 146 ret i16 %mul 147} 148 149define i16 @test_mul_by_9(i16 %x) { 150; X86-LABEL: test_mul_by_9: 151; X86: # %bb.0: 152; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 153; X86-NEXT: leal (%eax,%eax,8), %eax 154; X86-NEXT: # kill: def $ax killed $ax killed $eax 155; X86-NEXT: retl 156; 157; X64-LABEL: test_mul_by_9: 158; X64: # %bb.0: 159; X64-NEXT: # kill: def $edi killed $edi def $rdi 160; X64-NEXT: leal (%rdi,%rdi,8), %eax 161; X64-NEXT: # kill: def $ax killed $ax killed $eax 162; X64-NEXT: retq 163 %mul = mul nsw i16 %x, 9 164 ret i16 %mul 165} 166 167define i16 @test_mul_by_10(i16 %x) { 168; X86-LABEL: test_mul_by_10: 169; X86: # %bb.0: 170; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 171; X86-NEXT: addl %eax, %eax 172; X86-NEXT: leal (%eax,%eax,4), %eax 173; X86-NEXT: # kill: def $ax killed $ax killed $eax 174; X86-NEXT: retl 175; 176; X64-LABEL: test_mul_by_10: 177; X64: # %bb.0: 178; X64-NEXT: # kill: def $edi killed $edi def $rdi 179; X64-NEXT: addl %edi, %edi 180; X64-NEXT: leal (%rdi,%rdi,4), %eax 181; X64-NEXT: # kill: def $ax killed $ax killed $eax 182; X64-NEXT: retq 183 %mul = mul nsw i16 %x, 10 184 ret i16 %mul 185} 186 187define i16 @test_mul_by_11(i16 %x) { 188; X86-LABEL: test_mul_by_11: 189; X86: # %bb.0: 190; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 191; X86-NEXT: leal (%eax,%eax,4), %ecx 192; X86-NEXT: leal (%eax,%ecx,2), %eax 193; X86-NEXT: # kill: def $ax killed $ax killed $eax 194; X86-NEXT: retl 195; 196; X64-LABEL: test_mul_by_11: 197; X64: # %bb.0: 198; X64-NEXT: # kill: def $edi killed $edi def $rdi 199; X64-NEXT: leal (%rdi,%rdi,4), %eax 200; X64-NEXT: leal (%rdi,%rax,2), %eax 201; X64-NEXT: # kill: def $ax killed $ax killed $eax 202; X64-NEXT: retq 203 %mul = mul nsw i16 %x, 11 204 ret i16 %mul 205} 206 207define i16 @test_mul_by_12(i16 %x) { 208; X86-LABEL: test_mul_by_12: 209; X86: # %bb.0: 210; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 211; X86-NEXT: shll $2, %eax 212; X86-NEXT: leal (%eax,%eax,2), %eax 213; X86-NEXT: # kill: def $ax killed $ax killed $eax 214; X86-NEXT: retl 215; 216; X64-LABEL: test_mul_by_12: 217; X64: # %bb.0: 218; X64-NEXT: # kill: def $edi killed $edi def $rdi 219; X64-NEXT: shll $2, %edi 220; X64-NEXT: leal (%rdi,%rdi,2), %eax 221; X64-NEXT: # kill: def $ax killed $ax killed $eax 222; X64-NEXT: retq 223 %mul = mul nsw i16 %x, 12 224 ret i16 %mul 225} 226 227define i16 @test_mul_by_13(i16 %x) { 228; X86-LABEL: test_mul_by_13: 229; X86: # %bb.0: 230; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 231; X86-NEXT: leal (%eax,%eax,2), %ecx 232; X86-NEXT: leal (%eax,%ecx,4), %eax 233; X86-NEXT: # kill: def $ax killed $ax killed $eax 234; X86-NEXT: retl 235; 236; X64-LABEL: test_mul_by_13: 237; X64: # %bb.0: 238; X64-NEXT: # kill: def $edi killed $edi def $rdi 239; X64-NEXT: leal (%rdi,%rdi,2), %eax 240; X64-NEXT: leal (%rdi,%rax,4), %eax 241; X64-NEXT: # kill: def $ax killed $ax killed $eax 242; X64-NEXT: retq 243 %mul = mul nsw i16 %x, 13 244 ret i16 %mul 245} 246 247define i16 @test_mul_by_14(i16 %x) { 248; X86-LABEL: test_mul_by_14: 249; X86: # %bb.0: 250; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 251; X86-NEXT: movl %ecx, %eax 252; X86-NEXT: shll $4, %eax 253; X86-NEXT: subl %ecx, %eax 254; X86-NEXT: subl %ecx, %eax 255; X86-NEXT: # kill: def $ax killed $ax killed $eax 256; X86-NEXT: retl 257; 258; X64-LABEL: test_mul_by_14: 259; X64: # %bb.0: 260; X64-NEXT: movl %edi, %eax 261; X64-NEXT: shll $4, %eax 262; X64-NEXT: subl %edi, %eax 263; X64-NEXT: subl %edi, %eax 264; X64-NEXT: # kill: def $ax killed $ax killed $eax 265; X64-NEXT: retq 266 %mul = mul nsw i16 %x, 14 267 ret i16 %mul 268} 269 270define i16 @test_mul_by_15(i16 %x) { 271; X86-LABEL: test_mul_by_15: 272; X86: # %bb.0: 273; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 274; X86-NEXT: leal (%eax,%eax,4), %eax 275; X86-NEXT: leal (%eax,%eax,2), %eax 276; X86-NEXT: # kill: def $ax killed $ax killed $eax 277; X86-NEXT: retl 278; 279; X64-LABEL: test_mul_by_15: 280; X64: # %bb.0: 281; X64-NEXT: # kill: def $edi killed $edi def $rdi 282; X64-NEXT: leal (%rdi,%rdi,4), %eax 283; X64-NEXT: leal (%rax,%rax,2), %eax 284; X64-NEXT: # kill: def $ax killed $ax killed $eax 285; X64-NEXT: retq 286 %mul = mul nsw i16 %x, 15 287 ret i16 %mul 288} 289 290define i16 @test_mul_by_16(i16 %x) { 291; X86-LABEL: test_mul_by_16: 292; X86: # %bb.0: 293; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 294; X86-NEXT: shll $4, %eax 295; X86-NEXT: # kill: def $ax killed $ax killed $eax 296; X86-NEXT: retl 297; 298; X64-LABEL: test_mul_by_16: 299; X64: # %bb.0: 300; X64-NEXT: shll $4, %edi 301; X64-NEXT: movl %edi, %eax 302; X64-NEXT: retq 303 %mul = mul nsw i16 %x, 16 304 ret i16 %mul 305} 306 307define i16 @test_mul_by_17(i16 %x) { 308; X86-LABEL: test_mul_by_17: 309; X86: # %bb.0: 310; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 311; X86-NEXT: movl %ecx, %eax 312; X86-NEXT: shll $4, %eax 313; X86-NEXT: addl %ecx, %eax 314; X86-NEXT: # kill: def $ax killed $ax killed $eax 315; X86-NEXT: retl 316; 317; X64-LABEL: test_mul_by_17: 318; X64: # %bb.0: 319; X64-NEXT: # kill: def $edi killed $edi def $rdi 320; X64-NEXT: movl %edi, %eax 321; X64-NEXT: shll $4, %eax 322; X64-NEXT: leal (%rax,%rdi), %eax 323; X64-NEXT: # kill: def $ax killed $ax killed $eax 324; X64-NEXT: retq 325 %mul = mul nsw i16 %x, 17 326 ret i16 %mul 327} 328 329define i16 @test_mul_by_18(i16 %x) { 330; X86-LABEL: test_mul_by_18: 331; X86: # %bb.0: 332; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 333; X86-NEXT: addl %eax, %eax 334; X86-NEXT: leal (%eax,%eax,8), %eax 335; X86-NEXT: # kill: def $ax killed $ax killed $eax 336; X86-NEXT: retl 337; 338; X64-LABEL: test_mul_by_18: 339; X64: # %bb.0: 340; X64-NEXT: # kill: def $edi killed $edi def $rdi 341; X64-NEXT: addl %edi, %edi 342; X64-NEXT: leal (%rdi,%rdi,8), %eax 343; X64-NEXT: # kill: def $ax killed $ax killed $eax 344; X64-NEXT: retq 345 %mul = mul nsw i16 %x, 18 346 ret i16 %mul 347} 348 349define i16 @test_mul_by_19(i16 %x) { 350; X86-LABEL: test_mul_by_19: 351; X86: # %bb.0: 352; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 353; X86-NEXT: leal (%eax,%eax,8), %ecx 354; X86-NEXT: leal (%eax,%ecx,2), %eax 355; X86-NEXT: # kill: def $ax killed $ax killed $eax 356; X86-NEXT: retl 357; 358; X64-LABEL: test_mul_by_19: 359; X64: # %bb.0: 360; X64-NEXT: # kill: def $edi killed $edi def $rdi 361; X64-NEXT: leal (%rdi,%rdi,8), %eax 362; X64-NEXT: leal (%rdi,%rax,2), %eax 363; X64-NEXT: # kill: def $ax killed $ax killed $eax 364; X64-NEXT: retq 365 %mul = mul nsw i16 %x, 19 366 ret i16 %mul 367} 368 369define i16 @test_mul_by_20(i16 %x) { 370; X86-LABEL: test_mul_by_20: 371; X86: # %bb.0: 372; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 373; X86-NEXT: shll $2, %eax 374; X86-NEXT: leal (%eax,%eax,4), %eax 375; X86-NEXT: # kill: def $ax killed $ax killed $eax 376; X86-NEXT: retl 377; 378; X64-LABEL: test_mul_by_20: 379; X64: # %bb.0: 380; X64-NEXT: # kill: def $edi killed $edi def $rdi 381; X64-NEXT: shll $2, %edi 382; X64-NEXT: leal (%rdi,%rdi,4), %eax 383; X64-NEXT: # kill: def $ax killed $ax killed $eax 384; X64-NEXT: retq 385 %mul = mul nsw i16 %x, 20 386 ret i16 %mul 387} 388 389define i16 @test_mul_by_21(i16 %x) { 390; X86-LABEL: test_mul_by_21: 391; X86: # %bb.0: 392; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 393; X86-NEXT: leal (%eax,%eax,4), %ecx 394; X86-NEXT: leal (%eax,%ecx,4), %eax 395; X86-NEXT: # kill: def $ax killed $ax killed $eax 396; X86-NEXT: retl 397; 398; X64-LABEL: test_mul_by_21: 399; X64: # %bb.0: 400; X64-NEXT: # kill: def $edi killed $edi def $rdi 401; X64-NEXT: leal (%rdi,%rdi,4), %eax 402; X64-NEXT: leal (%rdi,%rax,4), %eax 403; X64-NEXT: # kill: def $ax killed $ax killed $eax 404; X64-NEXT: retq 405 %mul = mul nsw i16 %x, 21 406 ret i16 %mul 407} 408 409define i16 @test_mul_by_22(i16 %x) { 410; X86-LABEL: test_mul_by_22: 411; X86: # %bb.0: 412; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 413; X86-NEXT: leal (%ecx,%ecx,4), %eax 414; X86-NEXT: leal (%ecx,%eax,4), %eax 415; X86-NEXT: addl %ecx, %eax 416; X86-NEXT: # kill: def $ax killed $ax killed $eax 417; X86-NEXT: retl 418; 419; X64-LABEL: test_mul_by_22: 420; X64: # %bb.0: 421; X64-NEXT: # kill: def $edi killed $edi def $rdi 422; X64-NEXT: leal (%rdi,%rdi,4), %eax 423; X64-NEXT: leal (%rdi,%rax,4), %eax 424; X64-NEXT: addl %edi, %eax 425; X64-NEXT: # kill: def $ax killed $ax killed $eax 426; X64-NEXT: retq 427 %mul = mul nsw i16 %x, 22 428 ret i16 %mul 429} 430 431define i16 @test_mul_by_23(i16 %x) { 432; X86-LABEL: test_mul_by_23: 433; X86: # %bb.0: 434; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 435; X86-NEXT: leal (%ecx,%ecx,2), %eax 436; X86-NEXT: shll $3, %eax 437; X86-NEXT: subl %ecx, %eax 438; X86-NEXT: # kill: def $ax killed $ax killed $eax 439; X86-NEXT: retl 440; 441; X64-LABEL: test_mul_by_23: 442; X64: # %bb.0: 443; X64-NEXT: # kill: def $edi killed $edi def $rdi 444; X64-NEXT: leal (%rdi,%rdi,2), %eax 445; X64-NEXT: shll $3, %eax 446; X64-NEXT: subl %edi, %eax 447; X64-NEXT: # kill: def $ax killed $ax killed $eax 448; X64-NEXT: retq 449 %mul = mul nsw i16 %x, 23 450 ret i16 %mul 451} 452 453define i16 @test_mul_by_24(i16 %x) { 454; X86-LABEL: test_mul_by_24: 455; X86: # %bb.0: 456; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 457; X86-NEXT: shll $3, %eax 458; X86-NEXT: leal (%eax,%eax,2), %eax 459; X86-NEXT: # kill: def $ax killed $ax killed $eax 460; X86-NEXT: retl 461; 462; X64-LABEL: test_mul_by_24: 463; X64: # %bb.0: 464; X64-NEXT: # kill: def $edi killed $edi def $rdi 465; X64-NEXT: shll $3, %edi 466; X64-NEXT: leal (%rdi,%rdi,2), %eax 467; X64-NEXT: # kill: def $ax killed $ax killed $eax 468; X64-NEXT: retq 469 %mul = mul nsw i16 %x, 24 470 ret i16 %mul 471} 472 473define i16 @test_mul_by_25(i16 %x) { 474; X86-LABEL: test_mul_by_25: 475; X86: # %bb.0: 476; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 477; X86-NEXT: leal (%eax,%eax,4), %eax 478; X86-NEXT: leal (%eax,%eax,4), %eax 479; X86-NEXT: # kill: def $ax killed $ax killed $eax 480; X86-NEXT: retl 481; 482; X64-LABEL: test_mul_by_25: 483; X64: # %bb.0: 484; X64-NEXT: # kill: def $edi killed $edi def $rdi 485; X64-NEXT: leal (%rdi,%rdi,4), %eax 486; X64-NEXT: leal (%rax,%rax,4), %eax 487; X64-NEXT: # kill: def $ax killed $ax killed $eax 488; X64-NEXT: retq 489 %mul = mul nsw i16 %x, 25 490 ret i16 %mul 491} 492 493define i16 @test_mul_by_26(i16 %x) { 494; X86-LABEL: test_mul_by_26: 495; X86: # %bb.0: 496; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 497; X86-NEXT: leal (%ecx,%ecx,4), %eax 498; X86-NEXT: leal (%eax,%eax,4), %eax 499; X86-NEXT: addl %ecx, %eax 500; X86-NEXT: # kill: def $ax killed $ax killed $eax 501; X86-NEXT: retl 502; 503; X64-LABEL: test_mul_by_26: 504; X64: # %bb.0: 505; X64-NEXT: # kill: def $edi killed $edi def $rdi 506; X64-NEXT: leal (%rdi,%rdi,4), %eax 507; X64-NEXT: leal (%rax,%rax,4), %eax 508; X64-NEXT: addl %edi, %eax 509; X64-NEXT: # kill: def $ax killed $ax killed $eax 510; X64-NEXT: retq 511 %mul = mul nsw i16 %x, 26 512 ret i16 %mul 513} 514 515define i16 @test_mul_by_27(i16 %x) { 516; X86-LABEL: test_mul_by_27: 517; X86: # %bb.0: 518; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 519; X86-NEXT: leal (%eax,%eax,8), %eax 520; X86-NEXT: leal (%eax,%eax,2), %eax 521; X86-NEXT: # kill: def $ax killed $ax killed $eax 522; X86-NEXT: retl 523; 524; X64-LABEL: test_mul_by_27: 525; X64: # %bb.0: 526; X64-NEXT: # kill: def $edi killed $edi def $rdi 527; X64-NEXT: leal (%rdi,%rdi,8), %eax 528; X64-NEXT: leal (%rax,%rax,2), %eax 529; X64-NEXT: # kill: def $ax killed $ax killed $eax 530; X64-NEXT: retq 531 %mul = mul nsw i16 %x, 27 532 ret i16 %mul 533} 534 535define i16 @test_mul_by_28(i16 %x) { 536; X86-LABEL: test_mul_by_28: 537; X86: # %bb.0: 538; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 539; X86-NEXT: leal (%ecx,%ecx,8), %eax 540; X86-NEXT: leal (%eax,%eax,2), %eax 541; X86-NEXT: addl %ecx, %eax 542; X86-NEXT: # kill: def $ax killed $ax killed $eax 543; X86-NEXT: retl 544; 545; X64-LABEL: test_mul_by_28: 546; X64: # %bb.0: 547; X64-NEXT: # kill: def $edi killed $edi def $rdi 548; X64-NEXT: leal (%rdi,%rdi,8), %eax 549; X64-NEXT: leal (%rax,%rax,2), %eax 550; X64-NEXT: addl %edi, %eax 551; X64-NEXT: # kill: def $ax killed $ax killed $eax 552; X64-NEXT: retq 553 %mul = mul nsw i16 %x, 28 554 ret i16 %mul 555} 556 557define i16 @test_mul_by_29(i16 %x) { 558; X86-LABEL: test_mul_by_29: 559; X86: # %bb.0: 560; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 561; X86-NEXT: leal (%ecx,%ecx,8), %eax 562; X86-NEXT: leal (%eax,%eax,2), %eax 563; X86-NEXT: addl %ecx, %eax 564; X86-NEXT: addl %ecx, %eax 565; X86-NEXT: # kill: def $ax killed $ax killed $eax 566; X86-NEXT: retl 567; 568; X64-LABEL: test_mul_by_29: 569; X64: # %bb.0: 570; X64-NEXT: # kill: def $edi killed $edi def $rdi 571; X64-NEXT: leal (%rdi,%rdi,8), %eax 572; X64-NEXT: leal (%rax,%rax,2), %eax 573; X64-NEXT: addl %edi, %eax 574; X64-NEXT: addl %edi, %eax 575; X64-NEXT: # kill: def $ax killed $ax killed $eax 576; X64-NEXT: retq 577 %mul = mul nsw i16 %x, 29 578 ret i16 %mul 579} 580 581define i16 @test_mul_by_30(i16 %x) { 582; X86-LABEL: test_mul_by_30: 583; X86: # %bb.0: 584; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 585; X86-NEXT: movl %ecx, %eax 586; X86-NEXT: shll $5, %eax 587; X86-NEXT: subl %ecx, %eax 588; X86-NEXT: subl %ecx, %eax 589; X86-NEXT: # kill: def $ax killed $ax killed $eax 590; X86-NEXT: retl 591; 592; X64-LABEL: test_mul_by_30: 593; X64: # %bb.0: 594; X64-NEXT: movl %edi, %eax 595; X64-NEXT: shll $5, %eax 596; X64-NEXT: subl %edi, %eax 597; X64-NEXT: subl %edi, %eax 598; X64-NEXT: # kill: def $ax killed $ax killed $eax 599; X64-NEXT: retq 600 %mul = mul nsw i16 %x, 30 601 ret i16 %mul 602} 603 604define i16 @test_mul_by_31(i16 %x) { 605; X86-LABEL: test_mul_by_31: 606; X86: # %bb.0: 607; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 608; X86-NEXT: movl %ecx, %eax 609; X86-NEXT: shll $5, %eax 610; X86-NEXT: subl %ecx, %eax 611; X86-NEXT: # kill: def $ax killed $ax killed $eax 612; X86-NEXT: retl 613; 614; X64-LABEL: test_mul_by_31: 615; X64: # %bb.0: 616; X64-NEXT: movl %edi, %eax 617; X64-NEXT: shll $5, %eax 618; X64-NEXT: subl %edi, %eax 619; X64-NEXT: # kill: def $ax killed $ax killed $eax 620; X64-NEXT: retq 621 %mul = mul nsw i16 %x, 31 622 ret i16 %mul 623} 624 625define i16 @test_mul_by_32(i16 %x) { 626; X86-LABEL: test_mul_by_32: 627; X86: # %bb.0: 628; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 629; X86-NEXT: shll $5, %eax 630; X86-NEXT: # kill: def $ax killed $ax killed $eax 631; X86-NEXT: retl 632; 633; X64-LABEL: test_mul_by_32: 634; X64: # %bb.0: 635; X64-NEXT: shll $5, %edi 636; X64-NEXT: movl %edi, %eax 637; X64-NEXT: retq 638 %mul = mul nsw i16 %x, 32 639 ret i16 %mul 640} 641 642define i16 @test_mul_by_37(i16 %x) { 643; X86-LABEL: test_mul_by_37: 644; X86: # %bb.0: 645; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 646; X86-NEXT: leal (%eax,%eax,8), %ecx 647; X86-NEXT: leal (%eax,%ecx,4), %eax 648; X86-NEXT: # kill: def $ax killed $ax killed $eax 649; X86-NEXT: retl 650; 651; X64-LABEL: test_mul_by_37: 652; X64: # %bb.0: 653; X64-NEXT: # kill: def $edi killed $edi def $rdi 654; X64-NEXT: leal (%rdi,%rdi,8), %eax 655; X64-NEXT: leal (%rdi,%rax,4), %eax 656; X64-NEXT: # kill: def $ax killed $ax killed $eax 657; X64-NEXT: retq 658 %mul = mul nsw i16 %x, 37 659 ret i16 %mul 660} 661 662define i16 @test_mul_by_41(i16 %x) { 663; X86-LABEL: test_mul_by_41: 664; X86: # %bb.0: 665; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 666; X86-NEXT: leal (%eax,%eax,4), %ecx 667; X86-NEXT: leal (%eax,%ecx,8), %eax 668; X86-NEXT: # kill: def $ax killed $ax killed $eax 669; X86-NEXT: retl 670; 671; X64-LABEL: test_mul_by_41: 672; X64: # %bb.0: 673; X64-NEXT: # kill: def $edi killed $edi def $rdi 674; X64-NEXT: leal (%rdi,%rdi,4), %eax 675; X64-NEXT: leal (%rdi,%rax,8), %eax 676; X64-NEXT: # kill: def $ax killed $ax killed $eax 677; X64-NEXT: retq 678 %mul = mul nsw i16 %x, 41 679 ret i16 %mul 680} 681 682define i16 @test_mul_by_62(i16 %x) { 683; X86-LABEL: test_mul_by_62: 684; X86: # %bb.0: 685; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 686; X86-NEXT: movl %ecx, %eax 687; X86-NEXT: shll $6, %eax 688; X86-NEXT: subl %ecx, %eax 689; X86-NEXT: subl %ecx, %eax 690; X86-NEXT: # kill: def $ax killed $ax killed $eax 691; X86-NEXT: retl 692; 693; X64-LABEL: test_mul_by_62: 694; X64: # %bb.0: 695; X64-NEXT: movl %edi, %eax 696; X64-NEXT: shll $6, %eax 697; X64-NEXT: subl %edi, %eax 698; X64-NEXT: subl %edi, %eax 699; X64-NEXT: # kill: def $ax killed $ax killed $eax 700; X64-NEXT: retq 701 %mul = mul nsw i16 %x, 62 702 ret i16 %mul 703} 704 705define i16 @test_mul_by_66(i16 %x) { 706; X86-LABEL: test_mul_by_66: 707; X86: # %bb.0: 708; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 709; X86-NEXT: movl %eax, %ecx 710; X86-NEXT: shll $6, %ecx 711; X86-NEXT: leal (%ecx,%eax,2), %eax 712; X86-NEXT: # kill: def $ax killed $ax killed $eax 713; X86-NEXT: retl 714; 715; X64-LABEL: test_mul_by_66: 716; X64: # %bb.0: 717; X64-NEXT: # kill: def $edi killed $edi def $rdi 718; X64-NEXT: movl %edi, %eax 719; X64-NEXT: shll $6, %eax 720; X64-NEXT: leal (%rax,%rdi,2), %eax 721; X64-NEXT: # kill: def $ax killed $ax killed $eax 722; X64-NEXT: retq 723 %mul = mul nsw i16 %x, 66 724 ret i16 %mul 725} 726 727define i16 @test_mul_by_73(i16 %x) { 728; X86-LABEL: test_mul_by_73: 729; X86: # %bb.0: 730; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 731; X86-NEXT: leal (%eax,%eax,8), %ecx 732; X86-NEXT: leal (%eax,%ecx,8), %eax 733; X86-NEXT: # kill: def $ax killed $ax killed $eax 734; X86-NEXT: retl 735; 736; X64-LABEL: test_mul_by_73: 737; X64: # %bb.0: 738; X64-NEXT: # kill: def $edi killed $edi def $rdi 739; X64-NEXT: leal (%rdi,%rdi,8), %eax 740; X64-NEXT: leal (%rdi,%rax,8), %eax 741; X64-NEXT: # kill: def $ax killed $ax killed $eax 742; X64-NEXT: retq 743 %mul = mul nsw i16 %x, 73 744 ret i16 %mul 745} 746 747define i16 @test_mul_by_520(i16 %x) { 748; X86-LABEL: test_mul_by_520: 749; X86: # %bb.0: 750; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 751; X86-NEXT: movl %eax, %ecx 752; X86-NEXT: shll $9, %ecx 753; X86-NEXT: leal (%ecx,%eax,8), %eax 754; X86-NEXT: # kill: def $ax killed $ax killed $eax 755; X86-NEXT: retl 756; 757; X64-LABEL: test_mul_by_520: 758; X64: # %bb.0: 759; X64-NEXT: # kill: def $edi killed $edi def $rdi 760; X64-NEXT: movl %edi, %eax 761; X64-NEXT: shll $9, %eax 762; X64-NEXT: leal (%rax,%rdi,8), %eax 763; X64-NEXT: # kill: def $ax killed $ax killed $eax 764; X64-NEXT: retq 765 %mul = mul nsw i16 %x, 520 766 ret i16 %mul 767} 768 769define i16 @test_mul_by_neg10(i16 %x) { 770; X86-LABEL: test_mul_by_neg10: 771; X86: # %bb.0: 772; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 773; X86-NEXT: addl %eax, %eax 774; X86-NEXT: leal (%eax,%eax,4), %eax 775; X86-NEXT: negl %eax 776; X86-NEXT: # kill: def $ax killed $ax killed $eax 777; X86-NEXT: retl 778; 779; X64-LABEL: test_mul_by_neg10: 780; X64: # %bb.0: 781; X64-NEXT: # kill: def $edi killed $edi def $rdi 782; X64-NEXT: addl %edi, %edi 783; X64-NEXT: leal (%rdi,%rdi,4), %eax 784; X64-NEXT: negl %eax 785; X64-NEXT: # kill: def $ax killed $ax killed $eax 786; X64-NEXT: retq 787 %mul = mul nsw i16 %x, -10 788 ret i16 %mul 789} 790 791define i16 @test_mul_by_neg36(i16 %x) { 792; X86-LABEL: test_mul_by_neg36: 793; X86: # %bb.0: 794; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 795; X86-NEXT: shll $2, %eax 796; X86-NEXT: leal (%eax,%eax,8), %eax 797; X86-NEXT: negl %eax 798; X86-NEXT: # kill: def $ax killed $ax killed $eax 799; X86-NEXT: retl 800; 801; X64-LABEL: test_mul_by_neg36: 802; X64: # %bb.0: 803; X64-NEXT: # kill: def $edi killed $edi def $rdi 804; X64-NEXT: shll $2, %edi 805; X64-NEXT: leal (%rdi,%rdi,8), %eax 806; X64-NEXT: negl %eax 807; X64-NEXT: # kill: def $ax killed $ax killed $eax 808; X64-NEXT: retq 809 %mul = mul nsw i16 %x, -36 810 ret i16 %mul 811} 812 813; (x*9+42)*(x*5+2) 814define i16 @test_mul_spec(i16 %x) nounwind { 815; X86-LABEL: test_mul_spec: 816; X86: # %bb.0: 817; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 818; X86-NEXT: leal 42(%eax,%eax,8), %ecx 819; X86-NEXT: leal 2(%eax,%eax,4), %eax 820; X86-NEXT: imull %ecx, %eax 821; X86-NEXT: # kill: def $ax killed $ax killed $eax 822; X86-NEXT: retl 823; 824; X64-LABEL: test_mul_spec: 825; X64: # %bb.0: 826; X64-NEXT: # kill: def $edi killed $edi def $rdi 827; X64-NEXT: leal 42(%rdi,%rdi,8), %ecx 828; X64-NEXT: leal 2(%rdi,%rdi,4), %eax 829; X64-NEXT: imull %ecx, %eax 830; X64-NEXT: # kill: def $ax killed $ax killed $eax 831; X64-NEXT: retq 832 %mul = mul nsw i16 %x, 9 833 %add = add nsw i16 %mul, 42 834 %mul2 = mul nsw i16 %x, 5 835 %add2 = add nsw i16 %mul2, 2 836 %mul3 = mul nsw i16 %add, %add2 837 ret i16 %mul3 838} 839