1# RUN: llc -mtriple=s390x-linux-gnu -mcpu=z14 -start-before=greedy %s -o - \
2# RUN:   | FileCheck %s
3#
4# Test folding of a memory operand into logical compare with an immediate.
5
6--- |
7  define i32 @fun0(i32* %src, i32 %arg) { ret i32 0 }
8  define i64 @fun1(i64* %src, i64 %arg) { ret i64 0 }
9  define i32 @fun2(i32* %src, i32 %arg) { ret i32 0 }
10  define i64 @fun3(i64* %src, i64 %arg) { ret i64 0 }
11...
12
13
14# CHECK-LABEL: fun0:
15# CHECK-LABEL: .LBB0_2:
16# CHECK:	msc     %r0, 164(%r15)                  # 4-byte Folded Reload
17---
18name:            fun0
19alignment:       16
20tracksRegLiveness: true
21registers:
22  - { id: 0, class: grx32bit }
23  - { id: 1, class: grx32bit }
24  - { id: 2, class: addr64bit }
25  - { id: 3, class: gr32bit }
26  - { id: 4, class: grx32bit }
27  - { id: 5, class: grx32bit }
28  - { id: 6, class: gr32bit }
29  - { id: 7, class: gr32bit }
30  - { id: 8, class: gr32bit }
31liveins:
32  - { reg: '$r2d', virtual-reg: '%2' }
33  - { reg: '$r3l', virtual-reg: '%3' }
34frameInfo:
35  maxAlignment:    1
36  hasOpaqueSPAdjustment: true
37machineFunctionInfo: {}
38body:             |
39  bb.0:
40    successors: %bb.1(0x30000000), %bb.2(0x50000000)
41    liveins: $r2d, $r3l
42
43    %3:gr32bit = COPY $r3l
44    %2:addr64bit = COPY $r2d
45    %6:gr32bit = LHIMux 0
46    CHIMux %3, 0, implicit-def $cc
47    %8:gr32bit = LHIMux 0
48    BRC 14, 6, %bb.2, implicit killed $cc
49    J %bb.1
50
51  bb.1:
52    %8:gr32bit = LMux %2, 0, $noreg :: (load 4 from %ir.src)
53    INLINEASM &"", 1, 12, implicit-def dead early-clobber $r0d, 12, implicit-def dead early-clobber $r1d, 12, implicit-def dead early-clobber $r2d, 12, implicit-def dead early-clobber $r3d, 12, implicit-def dead early-clobber $r4d, 12, implicit-def dead early-clobber $r5d, 12, implicit-def dead early-clobber $r6d, 12, implicit-def dead early-clobber $r7d, 12, implicit-def dead early-clobber $r8d, 12, implicit-def dead early-clobber $r9d, 12, implicit-def dead early-clobber $r10d, 12, implicit-def dead early-clobber $r11d, 12, implicit-def dead early-clobber $r12d, 12, implicit-def dead early-clobber $r13d, 12, implicit-def dead early-clobber $r14d, 12, implicit-def early-clobber $r15d
54
55  bb.2:
56    INLINEASM &"", 1, 12, implicit-def dead early-clobber $r0d, 12, implicit-def dead early-clobber $r1d, 12, implicit-def dead early-clobber $r2d, 12, implicit-def dead early-clobber $r3d, 12, implicit-def dead early-clobber $r4d, 12, implicit-def dead early-clobber $r5d, 12, implicit-def dead early-clobber $r6d, 12, implicit-def dead early-clobber $r7d, 12, implicit-def dead early-clobber $r8d, 12, implicit-def dead early-clobber $r9d, 12, implicit-def dead early-clobber $r10d, 12, implicit-def dead early-clobber $r11d, 12, implicit-def dead early-clobber $r12d, 12, implicit-def dead early-clobber $r13d, 12, implicit-def dead early-clobber $r14d, 12, implicit-def early-clobber $r15d
57    %6:gr32bit = MSRKC %8, %6, implicit-def $cc
58    %6:gr32bit = LOCHIMux %6, 1, 14, 6, implicit killed $cc
59    %7:gr32bit = NRK %3, %6, implicit-def dead $cc
60    $r2l = COPY %7
61    Return implicit $r2l
62
63...
64
65
66# CHECK-LABEL: fun1:
67# CHECK-LABEL: .LBB1_2:
68# CHECK:	msc     %r0, 164(%r15)                  # 4-byte Folded Reload
69---
70name:            fun1
71alignment:       16
72tracksRegLiveness: true
73registers:
74  - { id: 0, class: grx32bit }
75  - { id: 1, class: grx32bit }
76  - { id: 2, class: addr64bit }
77  - { id: 3, class: gr32bit }
78  - { id: 4, class: grx32bit }
79  - { id: 5, class: grx32bit }
80  - { id: 6, class: gr32bit }
81  - { id: 7, class: gr32bit }
82  - { id: 8, class: gr32bit }
83liveins:
84  - { reg: '$r2d', virtual-reg: '%2' }
85  - { reg: '$r3l', virtual-reg: '%3' }
86frameInfo:
87  maxAlignment:    1
88  hasOpaqueSPAdjustment: true
89machineFunctionInfo: {}
90body:             |
91  bb.0:
92    successors: %bb.1(0x30000000), %bb.2(0x50000000)
93    liveins: $r2d, $r3l
94
95    %3:gr32bit = COPY $r3l
96    %2:addr64bit = COPY $r2d
97    %6:gr32bit = LHIMux 0
98    CHIMux %3, 0, implicit-def $cc
99    %8:gr32bit = LHIMux 0
100    BRC 14, 6, %bb.2, implicit killed $cc
101    J %bb.1
102
103  bb.1:
104    %8:gr32bit = LMux %2, 0, $noreg :: (load 4 from %ir.src)
105    INLINEASM &"", 1, 12, implicit-def dead early-clobber $r0d, 12, implicit-def dead early-clobber $r1d, 12, implicit-def dead early-clobber $r2d, 12, implicit-def dead early-clobber $r3d, 12, implicit-def dead early-clobber $r4d, 12, implicit-def dead early-clobber $r5d, 12, implicit-def dead early-clobber $r6d, 12, implicit-def dead early-clobber $r7d, 12, implicit-def dead early-clobber $r8d, 12, implicit-def dead early-clobber $r9d, 12, implicit-def dead early-clobber $r10d, 12, implicit-def dead early-clobber $r11d, 12, implicit-def dead early-clobber $r12d, 12, implicit-def dead early-clobber $r13d, 12, implicit-def dead early-clobber $r14d, 12, implicit-def early-clobber $r15d
106
107  bb.2:
108    INLINEASM &"", 1, 12, implicit-def dead early-clobber $r0d, 12, implicit-def dead early-clobber $r1d, 12, implicit-def dead early-clobber $r2d, 12, implicit-def dead early-clobber $r3d, 12, implicit-def dead early-clobber $r4d, 12, implicit-def dead early-clobber $r5d, 12, implicit-def dead early-clobber $r6d, 12, implicit-def dead early-clobber $r7d, 12, implicit-def dead early-clobber $r8d, 12, implicit-def dead early-clobber $r9d, 12, implicit-def dead early-clobber $r10d, 12, implicit-def dead early-clobber $r11d, 12, implicit-def dead early-clobber $r12d, 12, implicit-def dead early-clobber $r13d, 12, implicit-def dead early-clobber $r14d, 12, implicit-def early-clobber $r15d
109    %6:gr32bit = MSRKC %6, %8, implicit-def $cc
110    %6:gr32bit = LOCHIMux %6, 1, 14, 6, implicit killed $cc
111    %7:gr32bit = NRK %3, %6, implicit-def dead $cc
112    $r2l = COPY %7
113    Return implicit $r2l
114
115...
116
117
118# CHECK-LABEL: fun2:
119# CHECK-LABEL: .LBB2_2:
120# CHECK:	msgc    %r0, 168(%r15)                  # 8-byte Folded Reload
121---
122name:            fun2
123alignment:       16
124tracksRegLiveness: true
125registers:
126  - { id: 0, class: gr64bit }
127  - { id: 1, class: gr64bit }
128  - { id: 2, class: addr64bit }
129  - { id: 3, class: gr64bit }
130  - { id: 4, class: gr64bit }
131  - { id: 5, class: gr64bit }
132  - { id: 6, class: gr64bit }
133  - { id: 7, class: gr64bit }
134  - { id: 8, class: gr64bit }
135liveins:
136  - { reg: '$r2d', virtual-reg: '%2' }
137  - { reg: '$r3d', virtual-reg: '%3' }
138frameInfo:
139  maxAlignment:    1
140  hasOpaqueSPAdjustment: true
141machineFunctionInfo: {}
142body:             |
143  bb.0:
144    successors: %bb.1(0x30000000), %bb.2(0x50000000)
145    liveins: $r2d, $r3d
146
147    %3:gr64bit = COPY $r3d
148    %2:addr64bit = COPY $r2d
149    %6:gr64bit = LGHI 0
150    CGHI %3, 0, implicit-def $cc
151    %8:gr64bit = LGHI 0
152    BRC 14, 6, %bb.2, implicit killed $cc
153    J %bb.1
154
155  bb.1:
156    %8:gr64bit = LG %2, 0, $noreg :: (load 8 from %ir.src)
157    INLINEASM &"", 1, 12, implicit-def dead early-clobber $r0d, 12, implicit-def dead early-clobber $r1d, 12, implicit-def dead early-clobber $r2d, 12, implicit-def dead early-clobber $r3d, 12, implicit-def dead early-clobber $r4d, 12, implicit-def dead early-clobber $r5d, 12, implicit-def dead early-clobber $r6d, 12, implicit-def dead early-clobber $r7d, 12, implicit-def dead early-clobber $r8d, 12, implicit-def dead early-clobber $r9d, 12, implicit-def dead early-clobber $r10d, 12, implicit-def dead early-clobber $r11d, 12, implicit-def dead early-clobber $r12d, 12, implicit-def dead early-clobber $r13d, 12, implicit-def dead early-clobber $r14d, 12, implicit-def early-clobber $r15d
158
159  bb.2:
160    INLINEASM &"", 1, 12, implicit-def dead early-clobber $r0d, 12, implicit-def dead early-clobber $r1d, 12, implicit-def dead early-clobber $r2d, 12, implicit-def dead early-clobber $r3d, 12, implicit-def dead early-clobber $r4d, 12, implicit-def dead early-clobber $r5d, 12, implicit-def dead early-clobber $r6d, 12, implicit-def dead early-clobber $r7d, 12, implicit-def dead early-clobber $r8d, 12, implicit-def dead early-clobber $r9d, 12, implicit-def dead early-clobber $r10d, 12, implicit-def dead early-clobber $r11d, 12, implicit-def dead early-clobber $r12d, 12, implicit-def dead early-clobber $r13d, 12, implicit-def dead early-clobber $r14d, 12, implicit-def early-clobber $r15d
161    %6:gr64bit = MSGRKC %8, %6, implicit-def $cc
162    %6:gr64bit = LOCGHI %6, 1, 14, 6, implicit killed $cc
163    %7:gr64bit = NGRK %3, %6, implicit-def dead $cc
164    $r2d = COPY %7
165    Return implicit $r2d
166
167...
168
169
170# CHECK-LABEL: fun3:
171# CHECK-LABEL: .LBB3_2:
172# CHECK:	msgc    %r0, 168(%r15)                  # 8-byte Folded Reload
173---
174name:            fun3
175alignment:       16
176tracksRegLiveness: true
177registers:
178  - { id: 0, class: gr64bit }
179  - { id: 1, class: gr64bit }
180  - { id: 2, class: addr64bit }
181  - { id: 3, class: gr64bit }
182  - { id: 4, class: gr64bit }
183  - { id: 5, class: gr64bit }
184  - { id: 6, class: gr64bit }
185  - { id: 7, class: gr64bit }
186  - { id: 8, class: gr64bit }
187liveins:
188  - { reg: '$r2d', virtual-reg: '%2' }
189  - { reg: '$r3d', virtual-reg: '%3' }
190frameInfo:
191  maxAlignment:    1
192  hasOpaqueSPAdjustment: true
193machineFunctionInfo: {}
194body:             |
195  bb.0:
196    successors: %bb.1(0x30000000), %bb.2(0x50000000)
197    liveins: $r2d, $r3d
198
199    %3:gr64bit = COPY $r3d
200    %2:addr64bit = COPY $r2d
201    %6:gr64bit = LGHI 0
202    CGHI %3, 0, implicit-def $cc
203    %8:gr64bit = LGHI 0
204    BRC 14, 6, %bb.2, implicit killed $cc
205    J %bb.1
206
207  bb.1:
208    %8:gr64bit = LG %2, 0, $noreg :: (load 8 from %ir.src)
209    INLINEASM &"", 1, 12, implicit-def dead early-clobber $r0d, 12, implicit-def dead early-clobber $r1d, 12, implicit-def dead early-clobber $r2d, 12, implicit-def dead early-clobber $r3d, 12, implicit-def dead early-clobber $r4d, 12, implicit-def dead early-clobber $r5d, 12, implicit-def dead early-clobber $r6d, 12, implicit-def dead early-clobber $r7d, 12, implicit-def dead early-clobber $r8d, 12, implicit-def dead early-clobber $r9d, 12, implicit-def dead early-clobber $r10d, 12, implicit-def dead early-clobber $r11d, 12, implicit-def dead early-clobber $r12d, 12, implicit-def dead early-clobber $r13d, 12, implicit-def dead early-clobber $r14d, 12, implicit-def early-clobber $r15d
210
211  bb.2:
212    INLINEASM &"", 1, 12, implicit-def dead early-clobber $r0d, 12, implicit-def dead early-clobber $r1d, 12, implicit-def dead early-clobber $r2d, 12, implicit-def dead early-clobber $r3d, 12, implicit-def dead early-clobber $r4d, 12, implicit-def dead early-clobber $r5d, 12, implicit-def dead early-clobber $r6d, 12, implicit-def dead early-clobber $r7d, 12, implicit-def dead early-clobber $r8d, 12, implicit-def dead early-clobber $r9d, 12, implicit-def dead early-clobber $r10d, 12, implicit-def dead early-clobber $r11d, 12, implicit-def dead early-clobber $r12d, 12, implicit-def dead early-clobber $r13d, 12, implicit-def dead early-clobber $r14d, 12, implicit-def early-clobber $r15d
213    %6:gr64bit = MSGRKC %6, %8, implicit-def $cc
214    %6:gr64bit = LOCGHI %6, 1, 14, 6, implicit killed $cc
215    %7:gr64bit = NGRK %3, %6, implicit-def dead $cc
216    $r2d = COPY %7
217    Return implicit $r2d
218
219...
220