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