1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2# RUN: llc -mtriple=x86_64-linux-gnu -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s
3
4--- |
5  ; ModuleID = 'srem.ll'
6  source_filename = "srem.ll"
7  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
8
9  define i8 @test_srem_i8(i8 %arg1, i8 %arg2) {
10    %res = srem i8 %arg1, %arg2
11    ret i8 %res
12  }
13
14  define i16 @test_srem_i16(i16 %arg1, i16 %arg2) {
15    %res = srem i16 %arg1, %arg2
16    ret i16 %res
17  }
18
19  define i32 @test_srem_i32(i32 %arg1, i32 %arg2) {
20    %res = srem i32 %arg1, %arg2
21    ret i32 %res
22  }
23
24  define i64 @test_srem_i64(i64 %arg1, i64 %arg2) {
25    %res = srem i64 %arg1, %arg2
26    ret i64 %res
27  }
28
29...
30---
31name:            test_srem_i8
32alignment:       16
33exposesReturnsTwice: false
34legalized:       false
35regBankSelected: false
36selected:        false
37failedISel:      false
38tracksRegLiveness: true
39registers:
40  - { id: 0, class: _, preferred-register: '' }
41  - { id: 1, class: _, preferred-register: '' }
42  - { id: 2, class: _, preferred-register: '' }
43  - { id: 3, class: _, preferred-register: '' }
44  - { id: 4, class: _, preferred-register: '' }
45liveins:
46frameInfo:
47  isFrameAddressTaken: false
48  isReturnAddressTaken: false
49  hasStackMap:     false
50  hasPatchPoint:   false
51  stackSize:       0
52  offsetAdjustment: 0
53  maxAlignment:    0
54  adjustsStack:    false
55  hasCalls:        false
56  stackProtector:  ''
57  maxCallFrameSize: 4294967295
58  hasOpaqueSPAdjustment: false
59  hasVAStart:      false
60  hasMustTailInVarArgFunc: false
61  localFrameSize:  0
62  savePoint:       ''
63  restorePoint:    ''
64fixedStack:
65stack:
66constants:
67body:             |
68  bb.1 (%ir-block.0):
69    liveins: $edi, $esi
70
71    ; CHECK-LABEL: name: test_srem_i8
72    ; CHECK: liveins: $edi, $esi
73    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $edi
74    ; CHECK: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[COPY]](s32)
75    ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $esi
76    ; CHECK: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[COPY1]](s32)
77    ; CHECK: [[SREM:%[0-9]+]]:_(s8) = G_SREM [[TRUNC]], [[TRUNC1]]
78    ; CHECK: $al = COPY [[SREM]](s8)
79    ; CHECK: RET 0, implicit $al
80    %2:_(s32) = COPY $edi
81    %0:_(s8) = G_TRUNC %2(s32)
82    %3:_(s32) = COPY $esi
83    %1:_(s8) = G_TRUNC %3(s32)
84    %4:_(s8) = G_SREM %0, %1
85    $al = COPY %4(s8)
86    RET 0, implicit $al
87
88...
89---
90name:            test_srem_i16
91alignment:       16
92exposesReturnsTwice: false
93legalized:       false
94regBankSelected: false
95selected:        false
96failedISel:      false
97tracksRegLiveness: true
98registers:
99  - { id: 0, class: _, preferred-register: '' }
100  - { id: 1, class: _, preferred-register: '' }
101  - { id: 2, class: _, preferred-register: '' }
102  - { id: 3, class: _, preferred-register: '' }
103  - { id: 4, class: _, preferred-register: '' }
104liveins:
105frameInfo:
106  isFrameAddressTaken: false
107  isReturnAddressTaken: false
108  hasStackMap:     false
109  hasPatchPoint:   false
110  stackSize:       0
111  offsetAdjustment: 0
112  maxAlignment:    0
113  adjustsStack:    false
114  hasCalls:        false
115  stackProtector:  ''
116  maxCallFrameSize: 4294967295
117  hasOpaqueSPAdjustment: false
118  hasVAStart:      false
119  hasMustTailInVarArgFunc: false
120  localFrameSize:  0
121  savePoint:       ''
122  restorePoint:    ''
123fixedStack:
124stack:
125constants:
126body:             |
127  bb.1 (%ir-block.0):
128    liveins: $edi, $esi
129
130    ; CHECK-LABEL: name: test_srem_i16
131    ; CHECK: liveins: $edi, $esi
132    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $edi
133    ; CHECK: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s32)
134    ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $esi
135    ; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[COPY1]](s32)
136    ; CHECK: [[SREM:%[0-9]+]]:_(s16) = G_SREM [[TRUNC]], [[TRUNC1]]
137    ; CHECK: $ax = COPY [[SREM]](s16)
138    ; CHECK: RET 0, implicit $ax
139    %2:_(s32) = COPY $edi
140    %0:_(s16) = G_TRUNC %2(s32)
141    %3:_(s32) = COPY $esi
142    %1:_(s16) = G_TRUNC %3(s32)
143    %4:_(s16) = G_SREM %0, %1
144    $ax = COPY %4(s16)
145    RET 0, implicit $ax
146
147...
148---
149name:            test_srem_i32
150alignment:       16
151exposesReturnsTwice: false
152legalized:       false
153regBankSelected: false
154selected:        false
155failedISel:      false
156tracksRegLiveness: true
157registers:
158  - { id: 0, class: _, preferred-register: '' }
159  - { id: 1, class: _, preferred-register: '' }
160  - { id: 2, class: _, preferred-register: '' }
161liveins:
162frameInfo:
163  isFrameAddressTaken: false
164  isReturnAddressTaken: false
165  hasStackMap:     false
166  hasPatchPoint:   false
167  stackSize:       0
168  offsetAdjustment: 0
169  maxAlignment:    0
170  adjustsStack:    false
171  hasCalls:        false
172  stackProtector:  ''
173  maxCallFrameSize: 4294967295
174  hasOpaqueSPAdjustment: false
175  hasVAStart:      false
176  hasMustTailInVarArgFunc: false
177  localFrameSize:  0
178  savePoint:       ''
179  restorePoint:    ''
180fixedStack:
181stack:
182constants:
183body:             |
184  bb.1 (%ir-block.0):
185    liveins: $edi, $esi
186
187    ; CHECK-LABEL: name: test_srem_i32
188    ; CHECK: liveins: $edi, $esi
189    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $edi
190    ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $esi
191    ; CHECK: [[SREM:%[0-9]+]]:_(s32) = G_SREM [[COPY]], [[COPY1]]
192    ; CHECK: $eax = COPY [[SREM]](s32)
193    ; CHECK: RET 0, implicit $eax
194    %0:_(s32) = COPY $edi
195    %1:_(s32) = COPY $esi
196    %2:_(s32) = G_SREM %0, %1
197    $eax = COPY %2(s32)
198    RET 0, implicit $eax
199
200...
201---
202name:            test_srem_i64
203alignment:       16
204exposesReturnsTwice: false
205legalized:       false
206regBankSelected: false
207selected:        false
208failedISel:      false
209tracksRegLiveness: true
210registers:
211  - { id: 0, class: _, preferred-register: '' }
212  - { id: 1, class: _, preferred-register: '' }
213  - { id: 2, class: _, preferred-register: '' }
214liveins:
215frameInfo:
216  isFrameAddressTaken: false
217  isReturnAddressTaken: false
218  hasStackMap:     false
219  hasPatchPoint:   false
220  stackSize:       0
221  offsetAdjustment: 0
222  maxAlignment:    0
223  adjustsStack:    false
224  hasCalls:        false
225  stackProtector:  ''
226  maxCallFrameSize: 4294967295
227  hasOpaqueSPAdjustment: false
228  hasVAStart:      false
229  hasMustTailInVarArgFunc: false
230  localFrameSize:  0
231  savePoint:       ''
232  restorePoint:    ''
233fixedStack:
234stack:
235constants:
236body:             |
237  bb.1 (%ir-block.0):
238    liveins: $rdi, $rsi
239
240    ; CHECK-LABEL: name: test_srem_i64
241    ; CHECK: liveins: $rdi, $rsi
242    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $rdi
243    ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $rsi
244    ; CHECK: [[SREM:%[0-9]+]]:_(s64) = G_SREM [[COPY]], [[COPY1]]
245    ; CHECK: $rax = COPY [[SREM]](s64)
246    ; CHECK: RET 0, implicit $rax
247    %0:_(s64) = COPY $rdi
248    %1:_(s64) = COPY $rsi
249    %2:_(s64) = G_SREM %0, %1
250    $rax = COPY %2(s64)
251    RET 0, implicit $rax
252
253...
254