• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=i686-unknown | FileCheck %s --check-prefix=X32
3; RUN: llc < %s -mtriple=x86_64-unknown | FileCheck %s --check-prefix=X64
4
5define zeroext i8 @test_udivrem_zext_ah(i8 %x, i8 %y) {
6; X32-LABEL: test_udivrem_zext_ah:
7; X32:       # %bb.0:
8; X32-NEXT:    movzbl {{[0-9]+}}(%esp), %eax
9; X32-NEXT:    divb {{[0-9]+}}(%esp)
10; X32-NEXT:    movzbl %ah, %ecx
11; X32-NEXT:    movb %al, z
12; X32-NEXT:    movl %ecx, %eax
13; X32-NEXT:    retl
14;
15; X64-LABEL: test_udivrem_zext_ah:
16; X64:       # %bb.0:
17; X64-NEXT:    movzbl %dil, %eax
18; X64-NEXT:    divb %sil
19; X64-NEXT:    movzbl %ah, %ecx
20; X64-NEXT:    movb %al, {{.*}}(%rip)
21; X64-NEXT:    movl %ecx, %eax
22; X64-NEXT:    retq
23  %div = udiv i8 %x, %y
24  store i8 %div, i8* @z
25  %1 = urem i8 %x, %y
26  ret i8 %1
27}
28
29define zeroext i8 @test_urem_zext_ah(i8 %x, i8 %y) {
30; X32-LABEL: test_urem_zext_ah:
31; X32:       # %bb.0:
32; X32-NEXT:    movzbl {{[0-9]+}}(%esp), %eax
33; X32-NEXT:    divb {{[0-9]+}}(%esp)
34; X32-NEXT:    movzbl %ah, %eax
35; X32-NEXT:    # kill: def $al killed $al killed $eax
36; X32-NEXT:    retl
37;
38; X64-LABEL: test_urem_zext_ah:
39; X64:       # %bb.0:
40; X64-NEXT:    movzbl %dil, %eax
41; X64-NEXT:    divb %sil
42; X64-NEXT:    movzbl %ah, %eax
43; X64-NEXT:    # kill: def $al killed $al killed $eax
44; X64-NEXT:    retq
45  %1 = urem i8 %x, %y
46  ret i8 %1
47}
48
49define i8 @test_urem_noext_ah(i8 %x, i8 %y) {
50; X32-LABEL: test_urem_noext_ah:
51; X32:       # %bb.0:
52; X32-NEXT:    movb {{[0-9]+}}(%esp), %cl
53; X32-NEXT:    movzbl {{[0-9]+}}(%esp), %eax
54; X32-NEXT:    divb %cl
55; X32-NEXT:    movzbl %ah, %eax
56; X32-NEXT:    addb %cl, %al
57; X32-NEXT:    # kill: def $al killed $al killed $eax
58; X32-NEXT:    retl
59;
60; X64-LABEL: test_urem_noext_ah:
61; X64:       # %bb.0:
62; X64-NEXT:    movzbl %dil, %eax
63; X64-NEXT:    divb %sil
64; X64-NEXT:    movzbl %ah, %eax
65; X64-NEXT:    addb %sil, %al
66; X64-NEXT:    # kill: def $al killed $al killed $eax
67; X64-NEXT:    retq
68  %1 = urem i8 %x, %y
69  %2 = add i8 %1, %y
70  ret i8 %2
71}
72
73define i64 @test_urem_zext64_ah(i8 %x, i8 %y) {
74; X32-LABEL: test_urem_zext64_ah:
75; X32:       # %bb.0:
76; X32-NEXT:    movzbl {{[0-9]+}}(%esp), %eax
77; X32-NEXT:    divb {{[0-9]+}}(%esp)
78; X32-NEXT:    movzbl %ah, %eax
79; X32-NEXT:    xorl %edx, %edx
80; X32-NEXT:    retl
81;
82; X64-LABEL: test_urem_zext64_ah:
83; X64:       # %bb.0:
84; X64-NEXT:    movzbl %dil, %eax
85; X64-NEXT:    divb %sil
86; X64-NEXT:    movzbl %ah, %eax
87; X64-NEXT:    retq
88  %1 = urem i8 %x, %y
89  %2 = zext i8 %1 to i64
90  ret i64 %2
91}
92
93define signext i8 @test_sdivrem_sext_ah(i8 %x, i8 %y) {
94; X32-LABEL: test_sdivrem_sext_ah:
95; X32:       # %bb.0:
96; X32-NEXT:    movsbl {{[0-9]+}}(%esp), %eax
97; X32-NEXT:    idivb {{[0-9]+}}(%esp)
98; X32-NEXT:    movsbl %ah, %ecx
99; X32-NEXT:    movb %al, z
100; X32-NEXT:    movl %ecx, %eax
101; X32-NEXT:    retl
102;
103; X64-LABEL: test_sdivrem_sext_ah:
104; X64:       # %bb.0:
105; X64-NEXT:    movsbl %dil, %eax
106; X64-NEXT:    idivb %sil
107; X64-NEXT:    movsbl %ah, %ecx
108; X64-NEXT:    movb %al, {{.*}}(%rip)
109; X64-NEXT:    movl %ecx, %eax
110; X64-NEXT:    retq
111  %div = sdiv i8 %x, %y
112  store i8 %div, i8* @z
113  %1 = srem i8 %x, %y
114  ret i8 %1
115}
116
117define signext i8 @test_srem_sext_ah(i8 %x, i8 %y) {
118; X32-LABEL: test_srem_sext_ah:
119; X32:       # %bb.0:
120; X32-NEXT:    movsbl {{[0-9]+}}(%esp), %eax
121; X32-NEXT:    idivb {{[0-9]+}}(%esp)
122; X32-NEXT:    movsbl %ah, %eax
123; X32-NEXT:    # kill: def $al killed $al killed $eax
124; X32-NEXT:    retl
125;
126; X64-LABEL: test_srem_sext_ah:
127; X64:       # %bb.0:
128; X64-NEXT:    movsbl %dil, %eax
129; X64-NEXT:    idivb %sil
130; X64-NEXT:    movsbl %ah, %eax
131; X64-NEXT:    # kill: def $al killed $al killed $eax
132; X64-NEXT:    retq
133  %1 = srem i8 %x, %y
134  ret i8 %1
135}
136
137define i8 @test_srem_noext_ah(i8 %x, i8 %y) {
138; X32-LABEL: test_srem_noext_ah:
139; X32:       # %bb.0:
140; X32-NEXT:    movb {{[0-9]+}}(%esp), %cl
141; X32-NEXT:    movsbl {{[0-9]+}}(%esp), %eax
142; X32-NEXT:    idivb %cl
143; X32-NEXT:    movsbl %ah, %eax
144; X32-NEXT:    addb %cl, %al
145; X32-NEXT:    # kill: def $al killed $al killed $eax
146; X32-NEXT:    retl
147;
148; X64-LABEL: test_srem_noext_ah:
149; X64:       # %bb.0:
150; X64-NEXT:    movsbl %dil, %eax
151; X64-NEXT:    idivb %sil
152; X64-NEXT:    movsbl %ah, %eax
153; X64-NEXT:    addb %sil, %al
154; X64-NEXT:    # kill: def $al killed $al killed $eax
155; X64-NEXT:    retq
156  %1 = srem i8 %x, %y
157  %2 = add i8 %1, %y
158  ret i8 %2
159}
160
161define i64 @test_srem_sext64_ah(i8 %x, i8 %y) {
162; X32-LABEL: test_srem_sext64_ah:
163; X32:       # %bb.0:
164; X32-NEXT:    movsbl {{[0-9]+}}(%esp), %eax
165; X32-NEXT:    idivb {{[0-9]+}}(%esp)
166; X32-NEXT:    movsbl %ah, %eax
167; X32-NEXT:    movl %eax, %edx
168; X32-NEXT:    sarl $31, %edx
169; X32-NEXT:    retl
170;
171; X64-LABEL: test_srem_sext64_ah:
172; X64:       # %bb.0:
173; X64-NEXT:    movsbl %dil, %eax
174; X64-NEXT:    idivb %sil
175; X64-NEXT:    movsbl %ah, %eax
176; X64-NEXT:    cltq
177; X64-NEXT:    retq
178  %1 = srem i8 %x, %y
179  %2 = sext i8 %1 to i64
180  ret i64 %2
181}
182
183define i64 @pr25754(i8 %a, i8 %c) {
184; X32-LABEL: pr25754:
185; X32:       # %bb.0:
186; X32-NEXT:    movzbl {{[0-9]+}}(%esp), %eax
187; X32-NEXT:    divb {{[0-9]+}}(%esp)
188; X32-NEXT:    movzbl %ah, %ecx
189; X32-NEXT:    movzbl %al, %eax
190; X32-NEXT:    addl %ecx, %eax
191; X32-NEXT:    xorl %edx, %edx
192; X32-NEXT:    retl
193;
194; X64-LABEL: pr25754:
195; X64:       # %bb.0:
196; X64-NEXT:    movzbl %dil, %eax
197; X64-NEXT:    divb %sil
198; X64-NEXT:    movzbl %ah, %ecx
199; X64-NEXT:    movzbl %al, %eax
200; X64-NEXT:    addq %rcx, %rax
201; X64-NEXT:    retq
202  %r1 = urem i8 %a, %c
203  %d1 = udiv i8 %a, %c
204  %r2 = zext i8 %r1 to i64
205  %d2 = zext i8 %d1 to i64
206  %ret = add i64 %r2, %d2
207  ret i64 %ret
208}
209
210@z = external dso_local global i8
211