139 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 52; RUN: llc < %s -mtriple=x86_64-- -mcpu=k8 | FileCheck %s --check-prefixes=X643; RUN: llc < %s -mtriple=x86_64-- -mcpu=opteron | FileCheck %s --check-prefixes=X644; RUN: llc < %s -mtriple=x86_64-- -mcpu=athlon64 | FileCheck %s --check-prefixes=X645; RUN: llc < %s -mtriple=x86_64-- -mcpu=athlon-fx | FileCheck %s --check-prefixes=X646; RUN: llc < %s -mtriple=x86_64-- -mcpu=k8-sse3 | FileCheck %s --check-prefixes=X647; RUN: llc < %s -mtriple=x86_64-- -mcpu=opteron-sse3 | FileCheck %s --check-prefixes=X648; RUN: llc < %s -mtriple=x86_64-- -mcpu=athlon64-sse3 | FileCheck %s --check-prefixes=X649; RUN: llc < %s -mtriple=x86_64-- -mcpu=amdfam10 | FileCheck %s --check-prefixes=X6410; RUN: llc < %s -mtriple=x86_64-- -mcpu=btver1 | FileCheck %s --check-prefixes=X6411; RUN: llc < %s -mtriple=x86_64-- -mcpu=btver2 | FileCheck %s --check-prefixes=BMI12; RUN: llc < %s -mtriple=x86_64-- -mcpu=bdver1 | FileCheck %s --check-prefixes=BMI13; RUN: llc < %s -mtriple=x86_64-- -mcpu=bdver2 | FileCheck %s --check-prefixes=BMI14; RUN: llc < %s -mtriple=x86_64-- -mcpu=bdver3 | FileCheck %s --check-prefixes=BMI15; RUN: llc < %s -mtriple=x86_64-- -mcpu=bdver4 | FileCheck %s --check-prefixes=BMI2-SLOW16; RUN: llc < %s -mtriple=x86_64-- -mcpu=znver1 | FileCheck %s --check-prefixes=BMI2-SLOW17; RUN: llc < %s -mtriple=x86_64-- -mcpu=znver2 | FileCheck %s --check-prefixes=BMI2-SLOW18; RUN: llc < %s -mtriple=x86_64-- -mcpu=znver3 | FileCheck %s --check-prefixes=BMI2-FAST19; RUN: llc < %s -mtriple=x86_64-- -mcpu=znver4 | FileCheck %s --check-prefixes=BMI2-FAST20; RUN: llc < %s -mtriple=x86_64-- -mcpu=znver5 | FileCheck %s --check-prefixes=BMI2-FAST21 22; Verify that for the X86_64 processors that are known to have poor latency23; double precision shift instructions we do not generate 'shld' or 'shrd'24; instructions.25 26;uint64_t lshift(uint64_t a, uint64_t b, int c)27;{28; return (a << c) | (b >> (64-c));29;}30 31define i64 @lshift(i64 %a, i64 %b, i32 %c) nounwind readnone {32; X64-LABEL: lshift:33; X64: # %bb.0: # %entry34; X64-NEXT: movl %edx, %ecx35; X64-NEXT: movq %rsi, %rax36; X64-NEXT: shlq %cl, %rdi37; X64-NEXT: shrq %rax38; X64-NEXT: notb %cl39; X64-NEXT: # kill: def $cl killed $cl killed $ecx40; X64-NEXT: shrq %cl, %rax41; X64-NEXT: orq %rdi, %rax42; X64-NEXT: retq43;44; BMI-LABEL: lshift:45; BMI: # %bb.0: # %entry46; BMI-NEXT: movq %rsi, %rax47; BMI-NEXT: movl %edx, %ecx48; BMI-NEXT: shrq %rax49; BMI-NEXT: shlq %cl, %rdi50; BMI-NEXT: notb %cl51; BMI-NEXT: # kill: def $cl killed $cl killed $ecx52; BMI-NEXT: shrq %cl, %rax53; BMI-NEXT: orq %rdi, %rax54; BMI-NEXT: retq55;56; BMI2-SLOW-LABEL: lshift:57; BMI2-SLOW: # %bb.0: # %entry58; BMI2-SLOW-NEXT: # kill: def $edx killed $edx def $rdx59; BMI2-SLOW-NEXT: shlxq %rdx, %rdi, %rcx60; BMI2-SLOW-NEXT: notb %dl61; BMI2-SLOW-NEXT: shrq %rsi62; BMI2-SLOW-NEXT: shrxq %rdx, %rsi, %rax63; BMI2-SLOW-NEXT: orq %rcx, %rax64; BMI2-SLOW-NEXT: retq65;66; BMI2-FAST-LABEL: lshift:67; BMI2-FAST: # %bb.0: # %entry68; BMI2-FAST-NEXT: movl %edx, %ecx69; BMI2-FAST-NEXT: movq %rdi, %rax70; BMI2-FAST-NEXT: # kill: def $cl killed $cl killed $ecx71; BMI2-FAST-NEXT: shldq %cl, %rsi, %rax72; BMI2-FAST-NEXT: retq73entry:74 %sh_prom = zext i32 %c to i6475 %shl = shl i64 %a, %sh_prom76 %sub = sub nsw i32 64, %c77 %sh_prom1 = zext i32 %sub to i6478 %shr = lshr i64 %b, %sh_prom179 %or = or i64 %shr, %shl80 ret i64 %or81}82 83;uint64_t rshift(uint64_t a, uint64_t b, int c)84;{85; return (a >> c) | (b << (64-c));86;}87 88define i64 @rshift(i64 %a, i64 %b, i32 %c) nounwind readnone {89; X64-LABEL: rshift:90; X64: # %bb.0: # %entry91; X64-NEXT: movl %edx, %ecx92; X64-NEXT: shrq %cl, %rdi93; X64-NEXT: leaq (%rsi,%rsi), %rax94; X64-NEXT: notb %cl95; X64-NEXT: # kill: def $cl killed $cl killed $ecx96; X64-NEXT: shlq %cl, %rax97; X64-NEXT: orq %rdi, %rax98; X64-NEXT: retq99;100; BMI-LABEL: rshift:101; BMI: # %bb.0: # %entry102; BMI-NEXT: movl %edx, %ecx103; BMI-NEXT: leaq (%rsi,%rsi), %rax104; BMI-NEXT: shrq %cl, %rdi105; BMI-NEXT: notb %cl106; BMI-NEXT: # kill: def $cl killed $cl killed $ecx107; BMI-NEXT: shlq %cl, %rax108; BMI-NEXT: orq %rdi, %rax109; BMI-NEXT: retq110;111; BMI2-SLOW-LABEL: rshift:112; BMI2-SLOW: # %bb.0: # %entry113; BMI2-SLOW-NEXT: # kill: def $edx killed $edx def $rdx114; BMI2-SLOW-NEXT: shrxq %rdx, %rdi, %rcx115; BMI2-SLOW-NEXT: notb %dl116; BMI2-SLOW-NEXT: addq %rsi, %rsi117; BMI2-SLOW-NEXT: shlxq %rdx, %rsi, %rax118; BMI2-SLOW-NEXT: orq %rcx, %rax119; BMI2-SLOW-NEXT: retq120;121; BMI2-FAST-LABEL: rshift:122; BMI2-FAST: # %bb.0: # %entry123; BMI2-FAST-NEXT: movl %edx, %ecx124; BMI2-FAST-NEXT: movq %rdi, %rax125; BMI2-FAST-NEXT: # kill: def $cl killed $cl killed $ecx126; BMI2-FAST-NEXT: shrdq %cl, %rsi, %rax127; BMI2-FAST-NEXT: retq128entry:129 %sh_prom = zext i32 %c to i64130 %shr = lshr i64 %a, %sh_prom131 %sub = sub nsw i32 64, %c132 %sh_prom1 = zext i32 %sub to i64133 %shl = shl i64 %b, %sh_prom1134 %or = or i64 %shl, %shr135 ret i64 %or136}137 138 139