xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/x86-64-double-shifts-Oz-Os-O2.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=x86-64 -mcpu=bdver1 | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; clang -Oz -c test1.cpp -emit-llvm -S -o
4*9880d681SAndroid Build Coastguard Worker; Verify that we generate shld insruction when we are optimizing for size,
5*9880d681SAndroid Build Coastguard Worker; even for X86_64 processors that are known to have poor latency double
6*9880d681SAndroid Build Coastguard Worker; precision shift instructions.
7*9880d681SAndroid Build Coastguard Worker; uint64_t lshift10(uint64_t a, uint64_t b)
8*9880d681SAndroid Build Coastguard Worker; {
9*9880d681SAndroid Build Coastguard Worker;     return (a << 10) | (b >> 54);
10*9880d681SAndroid Build Coastguard Worker; }
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Worker; Function Attrs: minsize nounwind readnone uwtable
13*9880d681SAndroid Build Coastguard Workerdefine i64 @_Z8lshift10mm(i64 %a, i64 %b) #0 {
14*9880d681SAndroid Build Coastguard Workerentry:
15*9880d681SAndroid Build Coastguard Worker; CHECK:   shldq   $10
16*9880d681SAndroid Build Coastguard Worker  %shl = shl i64 %a, 10
17*9880d681SAndroid Build Coastguard Worker  %shr = lshr i64 %b, 54
18*9880d681SAndroid Build Coastguard Worker  %or = or i64 %shr, %shl
19*9880d681SAndroid Build Coastguard Worker  ret i64 %or
20*9880d681SAndroid Build Coastguard Worker}
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Workerattributes #0 = { minsize nounwind readnone uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard Worker
25*9880d681SAndroid Build Coastguard Worker; clang -Os -c test2.cpp -emit-llvm -S
26*9880d681SAndroid Build Coastguard Worker; Verify that we generate shld insruction when we are optimizing for size,
27*9880d681SAndroid Build Coastguard Worker; even for X86_64 processors that are known to have poor latency double
28*9880d681SAndroid Build Coastguard Worker; precision shift instructions.
29*9880d681SAndroid Build Coastguard Worker; uint64_t lshift11(uint64_t a, uint64_t b)
30*9880d681SAndroid Build Coastguard Worker; {
31*9880d681SAndroid Build Coastguard Worker;     return (a << 11) | (b >> 53);
32*9880d681SAndroid Build Coastguard Worker; }
33*9880d681SAndroid Build Coastguard Worker
34*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind optsize readnone uwtable
35*9880d681SAndroid Build Coastguard Workerdefine i64 @_Z8lshift11mm(i64 %a, i64 %b) #1 {
36*9880d681SAndroid Build Coastguard Workerentry:
37*9880d681SAndroid Build Coastguard Worker; CHECK:   shldq   $11
38*9880d681SAndroid Build Coastguard Worker  %shl = shl i64 %a, 11
39*9880d681SAndroid Build Coastguard Worker  %shr = lshr i64 %b, 53
40*9880d681SAndroid Build Coastguard Worker  %or = or i64 %shr, %shl
41*9880d681SAndroid Build Coastguard Worker  ret i64 %or
42*9880d681SAndroid Build Coastguard Worker}
43*9880d681SAndroid Build Coastguard Worker
44*9880d681SAndroid Build Coastguard Workerattributes #1 = { nounwind optsize readnone uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
45*9880d681SAndroid Build Coastguard Worker
46*9880d681SAndroid Build Coastguard Worker; clang -O2 -c test2.cpp -emit-llvm -S
47*9880d681SAndroid Build Coastguard Worker; Verify that we do not generate shld insruction when we are not optimizing
48*9880d681SAndroid Build Coastguard Worker; for size for X86_64 processors that are known to have poor latency double
49*9880d681SAndroid Build Coastguard Worker; precision shift instructions.
50*9880d681SAndroid Build Coastguard Worker; uint64_t lshift12(uint64_t a, uint64_t b)
51*9880d681SAndroid Build Coastguard Worker; {
52*9880d681SAndroid Build Coastguard Worker;     return (a << 12) | (b >> 52);
53*9880d681SAndroid Build Coastguard Worker; }
54*9880d681SAndroid Build Coastguard Worker
55*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind optsize readnone uwtable
56*9880d681SAndroid Build Coastguard Workerdefine i64 @_Z8lshift12mm(i64 %a, i64 %b) #2 {
57*9880d681SAndroid Build Coastguard Workerentry:
58*9880d681SAndroid Build Coastguard Worker; CHECK:       shlq    $12
59*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:  shrq    $52
60*9880d681SAndroid Build Coastguard Worker  %shl = shl i64 %a, 12
61*9880d681SAndroid Build Coastguard Worker  %shr = lshr i64 %b, 52
62*9880d681SAndroid Build Coastguard Worker  %or = or i64 %shr, %shl
63*9880d681SAndroid Build Coastguard Worker  ret i64 %or
64*9880d681SAndroid Build Coastguard Worker}
65*9880d681SAndroid Build Coastguard Worker
66*9880d681SAndroid Build Coastguard Workerattributes #2= { nounwind readnone uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
67*9880d681SAndroid Build Coastguard Worker
68