xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/x86-64-double-shifts-var.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=x86-64 -mcpu=athlon | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=x86-64 -mcpu=athlon-tbird | FileCheck %s
3*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=x86-64 -mcpu=athlon-4 | FileCheck %s
4*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=x86-64 -mcpu=athlon-xp | FileCheck %s
5*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=x86-64 -mcpu=athlon-mp | FileCheck %s
6*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=x86-64 -mcpu=k8 | FileCheck %s
7*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=x86-64 -mcpu=opteron | FileCheck %s
8*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=x86-64 -mcpu=athlon64 | FileCheck %s
9*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=x86-64 -mcpu=athlon-fx | FileCheck %s
10*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=x86-64 -mcpu=k8-sse3 | FileCheck %s
11*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=x86-64 -mcpu=opteron-sse3 | FileCheck %s
12*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=x86-64 -mcpu=athlon64-sse3 | FileCheck %s
13*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=x86-64 -mcpu=amdfam10 | FileCheck %s
14*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=x86-64 -mcpu=btver1 | FileCheck %s
15*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=x86-64 -mcpu=btver2 | FileCheck %s
16*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=x86-64 -mcpu=bdver1 | FileCheck %s
17*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=x86-64 -mcpu=bdver2 | FileCheck %s
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Worker; Verify that for the X86_64 processors that are known to have poor latency
20*9880d681SAndroid Build Coastguard Worker; double precision shift instructions we do not generate 'shld' or 'shrd'
21*9880d681SAndroid Build Coastguard Worker; instructions.
22*9880d681SAndroid Build Coastguard Worker
23*9880d681SAndroid Build Coastguard Worker;uint64_t lshift(uint64_t a, uint64_t b, int c)
24*9880d681SAndroid Build Coastguard Worker;{
25*9880d681SAndroid Build Coastguard Worker;    return (a << c) | (b >> (64-c));
26*9880d681SAndroid Build Coastguard Worker;}
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Workerdefine i64 @lshift(i64 %a, i64 %b, i32 %c) nounwind readnone {
29*9880d681SAndroid Build Coastguard Workerentry:
30*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: shld
31*9880d681SAndroid Build Coastguard Worker  %sh_prom = zext i32 %c to i64
32*9880d681SAndroid Build Coastguard Worker  %shl = shl i64 %a, %sh_prom
33*9880d681SAndroid Build Coastguard Worker  %sub = sub nsw i32 64, %c
34*9880d681SAndroid Build Coastguard Worker  %sh_prom1 = zext i32 %sub to i64
35*9880d681SAndroid Build Coastguard Worker  %shr = lshr i64 %b, %sh_prom1
36*9880d681SAndroid Build Coastguard Worker  %or = or i64 %shr, %shl
37*9880d681SAndroid Build Coastguard Worker  ret i64 %or
38*9880d681SAndroid Build Coastguard Worker}
39*9880d681SAndroid Build Coastguard Worker
40*9880d681SAndroid Build Coastguard Worker;uint64_t rshift(uint64_t a, uint64_t b, int c)
41*9880d681SAndroid Build Coastguard Worker;{
42*9880d681SAndroid Build Coastguard Worker;    return (a >> c) | (b << (64-c));
43*9880d681SAndroid Build Coastguard Worker;}
44*9880d681SAndroid Build Coastguard Worker
45*9880d681SAndroid Build Coastguard Workerdefine i64 @rshift(i64 %a, i64 %b, i32 %c) nounwind readnone {
46*9880d681SAndroid Build Coastguard Workerentry:
47*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: shrd
48*9880d681SAndroid Build Coastguard Worker  %sh_prom = zext i32 %c to i64
49*9880d681SAndroid Build Coastguard Worker  %shr = lshr i64 %a, %sh_prom
50*9880d681SAndroid Build Coastguard Worker  %sub = sub nsw i32 64, %c
51*9880d681SAndroid Build Coastguard Worker  %sh_prom1 = zext i32 %sub to i64
52*9880d681SAndroid Build Coastguard Worker  %shl = shl i64 %b, %sh_prom1
53*9880d681SAndroid Build Coastguard Worker  %or = or i64 %shl, %shr
54*9880d681SAndroid Build Coastguard Worker  ret i64 %or
55*9880d681SAndroid Build Coastguard Worker}
56*9880d681SAndroid Build Coastguard Worker
57*9880d681SAndroid Build Coastguard Worker
58