1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown | FileCheck %s
3 ; RUN: llc < %s -mtriple=x86_64--windows-msvc | FileCheck %s -check-prefix=CHECK-WIN
5 ; The Windows runtime doesn't have these.
6 ; CHECK-WIN-NOT: __ashlti3
7 ; CHECK-WIN-NOT: __ashrti3
8 ; CHECK-WIN-NOT: __lshrti3
10 define i64 @f0(i64 %val, i64 %amt) minsize optsize {
13 ; CHECK-NEXT: movq %rsi, %rcx
14 ; CHECK-NEXT: movq %rdi, %rax
15 ; CHECK-NEXT: # kill: def $cl killed $cl killed $rcx
16 ; CHECK-NEXT: shlq %cl, %rax
18 %res = shl i64 %val, %amt
22 define i32 @f1(i64 %x, i64 %y) minsize optsize {
25 ; CHECK-NEXT: movq %rsi, %rcx
26 ; CHECK-NEXT: movq %rdi, %rax
27 ; CHECK-NEXT: # kill: def $cl killed $cl killed $rcx
28 ; CHECK-NEXT: shlq %cl, %rax
29 ; CHECK-NEXT: # kill: def $eax killed $eax killed $rax
32 %b = trunc i64 %a to i32
36 define i32 @f2(i64 %x, i64 %y) minsize optsize {
39 ; CHECK-NEXT: movq %rsi, %rcx
40 ; CHECK-NEXT: movq %rdi, %rax
41 ; CHECK-NEXT: # kill: def $cl killed $cl killed $rcx
42 ; CHECK-NEXT: sarq %cl, %rax
43 ; CHECK-NEXT: # kill: def $eax killed $eax killed $rax
46 %b = trunc i64 %a to i32
50 define i32 @f3(i64 %x, i64 %y) minsize optsize {
53 ; CHECK-NEXT: movq %rsi, %rcx
54 ; CHECK-NEXT: movq %rdi, %rax
55 ; CHECK-NEXT: # kill: def $cl killed $cl killed $rcx
56 ; CHECK-NEXT: shrq %cl, %rax
57 ; CHECK-NEXT: # kill: def $eax killed $eax killed $rax
60 %b = trunc i64 %a to i32
64 define dso_local { i64, i64 } @shl128(i64 %x.coerce0, i64 %x.coerce1, i8 signext %y) minsize optsize {
65 ; CHECK-LABEL: shl128:
66 ; CHECK: # %bb.0: # %entry
67 ; CHECK-NEXT: pushq %rax
68 ; CHECK-NEXT: .cfi_def_cfa_offset 16
69 ; CHECK-NEXT: movzbl %dl, %edx
70 ; CHECK-NEXT: callq __ashlti3
71 ; CHECK-NEXT: popq %rcx
72 ; CHECK-NEXT: .cfi_def_cfa_offset 8
75 %x.sroa.2.0.insert.ext = zext i64 %x.coerce1 to i128
76 %x.sroa.2.0.insert.shift = shl nuw i128 %x.sroa.2.0.insert.ext, 64
77 %x.sroa.0.0.insert.ext = zext i64 %x.coerce0 to i128
78 %x.sroa.0.0.insert.insert = or i128 %x.sroa.2.0.insert.shift, %x.sroa.0.0.insert.ext
79 %conv = sext i8 %y to i32
80 %sh_prom = zext i32 %conv to i128
81 %shl = shl i128 %x.sroa.0.0.insert.insert, %sh_prom
82 %retval.sroa.0.0.extract.trunc = trunc i128 %shl to i64
83 %retval.sroa.2.0.extract.shift = lshr i128 %shl, 64
84 %retval.sroa.2.0.extract.trunc = trunc i128 %retval.sroa.2.0.extract.shift to i64
85 %.fca.0.insert = insertvalue { i64, i64 } undef, i64 %retval.sroa.0.0.extract.trunc, 0
86 %.fca.1.insert = insertvalue { i64, i64 } %.fca.0.insert, i64 %retval.sroa.2.0.extract.trunc, 1
87 ret { i64, i64 } %.fca.1.insert
90 define dso_local { i64, i64 } @ashr128(i64 %x.coerce0, i64 %x.coerce1, i8 signext %y) minsize optsize {
91 ; CHECK-LABEL: ashr128:
92 ; CHECK: # %bb.0: # %entry
93 ; CHECK-NEXT: pushq %rax
94 ; CHECK-NEXT: .cfi_def_cfa_offset 16
95 ; CHECK-NEXT: callq __ashrti3
96 ; CHECK-NEXT: popq %rcx
97 ; CHECK-NEXT: .cfi_def_cfa_offset 8
100 %x.sroa.2.0.insert.ext = zext i64 %x.coerce1 to i128
101 %x.sroa.2.0.insert.shift = shl nuw i128 %x.sroa.2.0.insert.ext, 64
102 %x.sroa.0.0.insert.ext = zext i64 %x.coerce0 to i128
103 %x.sroa.0.0.insert.insert = or i128 %x.sroa.2.0.insert.shift, %x.sroa.0.0.insert.ext
104 %conv = sext i8 %y to i32
105 %sh_prom = zext i32 %conv to i128
106 %shr = ashr i128 %x.sroa.0.0.insert.insert, %sh_prom
107 %retval.sroa.0.0.extract.trunc = trunc i128 %shr to i64
108 %retval.sroa.2.0.extract.shift = lshr i128 %shr, 64
109 %retval.sroa.2.0.extract.trunc = trunc i128 %retval.sroa.2.0.extract.shift to i64
110 %.fca.0.insert = insertvalue { i64, i64 } undef, i64 %retval.sroa.0.0.extract.trunc, 0
111 %.fca.1.insert = insertvalue { i64, i64 } %.fca.0.insert, i64 %retval.sroa.2.0.extract.trunc, 1
112 ret { i64, i64 } %.fca.1.insert
115 define dso_local { i64, i64 } @lshr128(i64 %x.coerce0, i64 %x.coerce1, i8 signext %y) minsize optsize {
116 ; CHECK-LABEL: lshr128:
117 ; CHECK: # %bb.0: # %entry
118 ; CHECK-NEXT: pushq %rax
119 ; CHECK-NEXT: .cfi_def_cfa_offset 16
120 ; CHECK-NEXT: movzbl %dl, %edx
121 ; CHECK-NEXT: callq __lshrti3
122 ; CHECK-NEXT: popq %rcx
123 ; CHECK-NEXT: .cfi_def_cfa_offset 8
126 %x.sroa.2.0.insert.ext = zext i64 %x.coerce1 to i128
127 %x.sroa.2.0.insert.shift = shl nuw i128 %x.sroa.2.0.insert.ext, 64
128 %x.sroa.0.0.insert.ext = zext i64 %x.coerce0 to i128
129 %x.sroa.0.0.insert.insert = or i128 %x.sroa.2.0.insert.shift, %x.sroa.0.0.insert.ext
130 %conv = sext i8 %y to i32
131 %sh_prom = zext i32 %conv to i128
132 %shr = lshr i128 %x.sroa.0.0.insert.insert, %sh_prom
133 %retval.sroa.0.0.extract.trunc = trunc i128 %shr to i64
134 %retval.sroa.2.0.extract.shift = lshr i128 %shr, 64
135 %retval.sroa.2.0.extract.trunc = trunc i128 %retval.sroa.2.0.extract.shift to i64
136 %.fca.0.insert = insertvalue { i64, i64 } undef, i64 %retval.sroa.0.0.extract.trunc, 0
137 %.fca.1.insert = insertvalue { i64, i64 } %.fca.0.insert, i64 %retval.sroa.2.0.extract.trunc, 1
138 ret { i64, i64 } %.fca.1.insert