1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -global-isel=0 -mtriple=x86_64-linux-gnu | FileCheck %s --check-prefixes=X64,SDAG-X64
3 ; RUN: llc < %s -fast-isel -fast-isel-abort=1 -mtriple=x86_64-linux-gnu | FileCheck %s --check-prefixes=X64,FAST-X64
4 ; RUN: llc < %s -global-isel -global-isel-abort=1 -mtriple=x86_64-linux-gnu | FileCheck %s --check-prefixes=X64,GISEL-X64
5 ; RUN: llc < %s -global-isel=0 -mtriple=i686-linux-gnu | FileCheck %s --check-prefixes=X86,DAG-X86,SDAG-X86
6 ; RUN: llc < %s -fast-isel -fast-isel-abort=1 -mtriple=i686-linux-gnu | FileCheck %s --check-prefixes=X86,DAG-X86,FAST-X86
7 ; RUN: llc < %s -global-isel -global-isel-abort=1 -mtriple=i686-linux-gnu | FileCheck %s --check-prefixes=X86,GISEL-X86
9 define i8 @test_srem_i8(i8 %arg1, i8 %arg2) nounwind {
10 ; SDAG-X64-LABEL: test_srem_i8:
12 ; SDAG-X64-NEXT: movsbl %dil, %eax
13 ; SDAG-X64-NEXT: idivb %sil
14 ; SDAG-X64-NEXT: movsbl %ah, %eax
15 ; SDAG-X64-NEXT: # kill: def $al killed $al killed $eax
18 ; FAST-X64-LABEL: test_srem_i8:
20 ; FAST-X64-NEXT: movsbl %dil, %eax
21 ; FAST-X64-NEXT: idivb %sil
22 ; FAST-X64-NEXT: shrw $8, %ax
23 ; FAST-X64-NEXT: # kill: def $al killed $al killed $ax
26 ; GISEL-X64-LABEL: test_srem_i8:
28 ; GISEL-X64-NEXT: movsbl %dil, %eax
29 ; GISEL-X64-NEXT: idivb %sil
30 ; GISEL-X64-NEXT: shrw $8, %ax
31 ; GISEL-X64-NEXT: # kill: def $al killed $al killed $ax
32 ; GISEL-X64-NEXT: retq
34 ; SDAG-X86-LABEL: test_srem_i8:
36 ; SDAG-X86-NEXT: movsbl {{[0-9]+}}(%esp), %eax
37 ; SDAG-X86-NEXT: idivb {{[0-9]+}}(%esp)
38 ; SDAG-X86-NEXT: movsbl %ah, %eax
39 ; SDAG-X86-NEXT: # kill: def $al killed $al killed $eax
42 ; FAST-X86-LABEL: test_srem_i8:
44 ; FAST-X86-NEXT: movsbl {{[0-9]+}}(%esp), %eax
45 ; FAST-X86-NEXT: idivb {{[0-9]+}}(%esp)
46 ; FAST-X86-NEXT: movb %ah, %al
49 ; GISEL-X86-LABEL: test_srem_i8:
51 ; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %eax
52 ; GISEL-X86-NEXT: cbtw
53 ; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
54 ; GISEL-X86-NEXT: idivb %cl
55 ; GISEL-X86-NEXT: movb %ah, %al
56 ; GISEL-X86-NEXT: retl
57 %ret = srem i8 %arg1, %arg2
61 define i16 @test_srem_i16(i16 %arg1, i16 %arg2) nounwind {
62 ; X64-LABEL: test_srem_i16:
64 ; X64-NEXT: movl %edi, %eax
65 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
68 ; X64-NEXT: movl %edx, %eax
71 ; DAG-X86-LABEL: test_srem_i16:
73 ; DAG-X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
75 ; DAG-X86-NEXT: idivw {{[0-9]+}}(%esp)
76 ; DAG-X86-NEXT: movl %edx, %eax
79 ; GISEL-X86-LABEL: test_srem_i16:
81 ; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %eax
82 ; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
83 ; GISEL-X86-NEXT: # kill: def $ax killed $ax killed $eax
84 ; GISEL-X86-NEXT: cwtd
85 ; GISEL-X86-NEXT: idivw %cx
86 ; GISEL-X86-NEXT: movl %edx, %eax
87 ; GISEL-X86-NEXT: retl
88 %ret = srem i16 %arg1, %arg2
92 define i32 @test_srem_i32(i32 %arg1, i32 %arg2) nounwind {
93 ; X64-LABEL: test_srem_i32:
95 ; X64-NEXT: movl %edi, %eax
97 ; X64-NEXT: idivl %esi
98 ; X64-NEXT: movl %edx, %eax
101 ; X86-LABEL: test_srem_i32:
103 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
105 ; X86-NEXT: idivl {{[0-9]+}}(%esp)
106 ; X86-NEXT: movl %edx, %eax
108 %ret = srem i32 %arg1, %arg2
112 define i64 @test_srem_i64(i64 %arg1, i64 %arg2) nounwind {
113 ; X64-LABEL: test_srem_i64:
115 ; X64-NEXT: movq %rdi, %rax
117 ; X64-NEXT: idivq %rsi
118 ; X64-NEXT: movq %rdx, %rax
121 ; DAG-X86-LABEL: test_srem_i64:
123 ; DAG-X86-NEXT: subl $12, %esp
124 ; DAG-X86-NEXT: pushl {{[0-9]+}}(%esp)
125 ; DAG-X86-NEXT: pushl {{[0-9]+}}(%esp)
126 ; DAG-X86-NEXT: pushl {{[0-9]+}}(%esp)
127 ; DAG-X86-NEXT: pushl {{[0-9]+}}(%esp)
128 ; DAG-X86-NEXT: calll __moddi3
129 ; DAG-X86-NEXT: addl $28, %esp
132 ; GISEL-X86-LABEL: test_srem_i64:
133 ; GISEL-X86: # %bb.0:
134 ; GISEL-X86-NEXT: pushl %esi
135 ; GISEL-X86-NEXT: subl $24, %esp
136 ; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %eax
137 ; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
138 ; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %edx
139 ; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %esi
140 ; GISEL-X86-NEXT: movl %eax, (%esp)
141 ; GISEL-X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
142 ; GISEL-X86-NEXT: movl %edx, {{[0-9]+}}(%esp)
143 ; GISEL-X86-NEXT: movl %esi, {{[0-9]+}}(%esp)
144 ; GISEL-X86-NEXT: calll __moddi3
145 ; GISEL-X86-NEXT: addl $24, %esp
146 ; GISEL-X86-NEXT: popl %esi
147 ; GISEL-X86-NEXT: retl
148 %ret = srem i64 %arg1, %arg2