1; RUN: llc < %s -mtriple=x86_64-pc-linux-gnu | FileCheck %s --check-prefix=X64 2; RUN: llc < %s -mtriple=x86_64-pc-linux-gnux32 | FileCheck %s --check-prefix=X64 3; RUN: llc < %s -mtriple=i686-pc-linux | FileCheck %s --check-prefix=X86 4 5define i32 @mul4_32(i32 %A) { 6; X64-LABEL: mul4_32: 7; X64: leal 8; X86-LABEL: mul4_32: 9; X86: shll 10 %mul = mul i32 %A, 4 11 ret i32 %mul 12} 13 14define i64 @mul4_64(i64 %A) { 15; X64-LABEL: mul4_64: 16; X64: leaq 17; X86-LABEL: mul4_64: 18; X86: shldl 19; X86: shll 20 %mul = mul i64 %A, 4 21 ret i64 %mul 22} 23 24define i32 @mul4096_32(i32 %A) { 25; X64-LABEL: mul4096_32: 26; X64: shll 27; X86-LABEL: mul4096_32: 28; X86: shll 29 %mul = mul i32 %A, 4096 30 ret i32 %mul 31} 32 33define i64 @mul4096_64(i64 %A) { 34; X64-LABEL: mul4096_64: 35; X64: shlq 36; X86-LABEL: mul4096_64: 37; X86: shldl 38; X86: shll 39 %mul = mul i64 %A, 4096 40 ret i64 %mul 41} 42 43define i32 @mulmin4096_32(i32 %A) { 44; X64-LABEL: mulmin4096_32: 45; X64: shll 46; X64-NEXT: negl 47; X86-LABEL: mulmin4096_32: 48; X86: shll 49; X86-NEXT: negl 50 %mul = mul i32 %A, -4096 51 ret i32 %mul 52} 53 54define i64 @mulmin4096_64(i64 %A) { 55; X64-LABEL: mulmin4096_64: 56; X64: shlq 57; X64-NEXT: negq 58; X86-LABEL: mulmin4096_64: 59; X86: shldl 60; X86-NEXT: shll 61; X86-NEXT: xorl 62; X86-NEXT: negl 63; X86-NEXT: sbbl 64 %mul = mul i64 %A, -4096 65 ret i64 %mul 66} 67 68define i32 @mul3_32(i32 %A) { 69; X64-LABEL: mul3_32: 70; X64: leal 71; X86-LABEL: mul3_32: 72; But why?! 73; X86: imull 74 %mul = mul i32 %A, 3 75 ret i32 %mul 76} 77 78define i64 @mul3_64(i64 %A) { 79; X64-LABEL: mul3_64: 80; X64: leaq 81; X86-LABEL: mul3_64: 82; X86: mull 83; X86-NEXT: imull 84 %mul = mul i64 %A, 3 85 ret i64 %mul 86} 87 88define i32 @mul40_32(i32 %A) { 89; X64-LABEL: mul40_32: 90; X64: shll 91; X64-NEXT: leal 92; X86-LABEL: mul40_32: 93; X86: shll 94; X86-NEXT: leal 95 %mul = mul i32 %A, 40 96 ret i32 %mul 97} 98 99define i64 @mul40_64(i64 %A) { 100; X64-LABEL: mul40_64: 101; X64: shlq 102; X64-NEXT: leaq 103; X86-LABEL: mul40_64: 104; X86: leal 105; X86-NEXT: movl 106; X86-NEXT: mull 107; X86-NEXT: leal 108 %mul = mul i64 %A, 40 109 ret i64 %mul 110} 111 112define i32 @mul4_32_minsize(i32 %A) minsize { 113; X64-LABEL: mul4_32_minsize: 114; X64: leal 115; X86-LABEL: mul4_32_minsize: 116; X86: shll 117 %mul = mul i32 %A, 4 118 ret i32 %mul 119} 120 121define i32 @mul40_32_minsize(i32 %A) minsize { 122; X64-LABEL: mul40_32_minsize: 123; X64: imull 124; X86-LABEL: mul40_32_minsize: 125; X86: imull 126 %mul = mul i32 %A, 40 127 ret i32 %mul 128} 129 130define i32 @mul33_32(i32 %A) { 131; X64-LABEL: mul33_32: 132; X64: shll 133; X64-NEXT: leal 134; X86-LABEL: mul33_32: 135; X86: shll 136; X86-NEXT: addl 137 %mul = mul i32 %A, 33 138 ret i32 %mul 139} 140 141define i32 @mul31_32(i32 %A) { 142; X64-LABEL: mul31_32: 143; X64: shll 144; X64-NEXT: subl 145; X86-LABEL: mul31_32: 146; X86: shll 147; X86-NEXT: subl 148 %mul = mul i32 %A, 31 149 ret i32 %mul 150} 151 152define i32 @mul0_32(i32 %A) { 153; X64-LABEL: mul0_32: 154; X64: xorl %eax, %eax 155 %mul = mul i32 %A, 0 156 ret i32 %mul 157} 158 159define i32 @mul4294967295_32(i32 %A) { 160; X64-LABEL: mul4294967295_32: 161; X64: negl %edi 162; X64-NEXT: movl %edi, %eax 163 %mul = mul i32 %A, 4294967295 164 ret i32 %mul 165} 166 167define i64 @mul18446744073709551615_64(i64 %A) { 168; X64-LABEL: mul18446744073709551615_64: 169; X64: negq %rdi 170; X64-NEXT: movq %rdi, %rax 171 %mul = mul i64 %A, 18446744073709551615 172 ret i64 %mul 173} 174