1# RUN: llc -verify-machineinstrs -mcpu=pwr9 -mtriple powerpc64le-unknown-linux-gnu \
2# RUN:   -run-pass=block-placement -o - %s | FileCheck %s
3--- |
4  ; ModuleID = 'block-placement.ll'
5  source_filename = "block-placement.ll"
6  target datalayout = "e-m:e-i64:64-n32:64"
7  target triple = "powerpc64le-unknown-linux-gnu"
8
9  %"class.xercesc_2_7::HashXMLCh" = type { %"class.xercesc_2_7::HashBase" }
10  %"class.xercesc_2_7::HashBase" = type { i32 (...)** }
11
12  define dso_local zeroext i1 @_ZN11xercesc_2_79HashXMLCh6equalsEPKvS2_(%"class.xercesc_2_7::HashXMLCh"* nocapture readnone %this, i8* readonly %key1, i8* readonly %key2) unnamed_addr #0 {
13  entry:
14    %cmp.i = icmp eq i8* %key1, null
15    %cmp1.i = icmp eq i8* %key2, null
16    %or.cond.i = or i1 %cmp.i, %cmp1.i
17    br i1 %or.cond.i, label %if.then.i, label %while.cond.preheader.i
18
19  while.cond.preheader.i:                           ; preds = %entry
20    %0 = bitcast i8* %key2 to i16*
21    %1 = bitcast i8* %key1 to i16*
22    %2 = load i16, i16* %1, align 2
23    %3 = load i16, i16* %0, align 2
24    %cmp926.i = icmp eq i16 %2, %3
25    br i1 %cmp926.i, label %while.body.i.preheader, label %_ZN11xercesc_2_79XMLString6equalsEPKtS2_.exit
26
27  while.body.i.preheader:                           ; preds = %while.cond.preheader.i
28    %scevgep = getelementptr i8, i8* %key2, i64 2
29    %scevgep4 = getelementptr i8, i8* %key1, i64 2
30    br label %while.body.i
31
32  if.then.i:                                        ; preds = %entry
33    br i1 %cmp.i, label %lor.lhs.false3.i, label %land.lhs.true.i
34
35  land.lhs.true.i:                                  ; preds = %if.then.i
36    %4 = bitcast i8* %key1 to i16*
37    %5 = load i16, i16* %4, align 2
38    %tobool.i = icmp eq i16 %5, 0
39    br i1 %tobool.i, label %lor.lhs.false3.i, label %_ZN11xercesc_2_79XMLString6equalsEPKtS2_.exit
40
41  lor.lhs.false3.i:                                 ; preds = %land.lhs.true.i, %if.then.i
42    br i1 %cmp1.i, label %if.else.i, label %land.lhs.true5.i
43
44  land.lhs.true5.i:                                 ; preds = %lor.lhs.false3.i
45    %6 = bitcast i8* %key2 to i16*
46    %7 = load i16, i16* %6, align 2
47    %tobool6.i = icmp eq i16 %7, 0
48    br i1 %tobool6.i, label %if.else.i, label %_ZN11xercesc_2_79XMLString6equalsEPKtS2_.exit
49
50  if.else.i:                                        ; preds = %land.lhs.true5.i, %lor.lhs.false3.i
51    br label %_ZN11xercesc_2_79XMLString6equalsEPKtS2_.exit
52
53  while.body.i:                                     ; preds = %while.body.i.preheader, %if.end12.i
54    %lsr.iv5 = phi i8* [ %scevgep4, %while.body.i.preheader ], [ %scevgep6, %if.end12.i ]
55    %lsr.iv = phi i8* [ %scevgep, %while.body.i.preheader ], [ %scevgep2, %if.end12.i ]
56    %8 = phi i16 [ %15, %if.end12.i ], [ %2, %while.body.i.preheader ]
57    %9 = phi i8* [ %key1, %while.body.i.preheader ], [ %13, %if.end12.i ]
58    %10 = phi i8* [ %key2, %while.body.i.preheader ], [ %11, %if.end12.i ]
59    %11 = getelementptr i8, i8* %10, i64 2
60    %12 = bitcast i8* %11 to i16*
61    %13 = getelementptr i8, i8* %9, i64 2
62    %14 = bitcast i8* %13 to i16*
63    %tobool10.i = icmp eq i16 %8, 0
64    br i1 %tobool10.i, label %_ZN11xercesc_2_79XMLString6equalsEPKtS2_.exit, label %if.end12.i
65
66  if.end12.i:                                       ; preds = %while.body.i
67    %15 = load i16, i16* %14, align 2
68    %16 = load i16, i16* %12, align 2
69    %cmp9.i = icmp eq i16 %15, %16
70    %scevgep2 = getelementptr i8, i8* %lsr.iv, i64 2
71    %scevgep6 = getelementptr i8, i8* %lsr.iv5, i64 2
72    br i1 %cmp9.i, label %while.body.i, label %_ZN11xercesc_2_79XMLString6equalsEPKtS2_.exit
73
74  _ZN11xercesc_2_79XMLString6equalsEPKtS2_.exit:    ; preds = %if.end12.i, %while.body.i, %if.else.i, %land.lhs.true5.i, %land.lhs.true.i, %while.cond.preheader.i
75    %retval.0.i1 = phi i64 [ 1, %if.else.i ], [ 0, %land.lhs.true.i ], [ 0, %land.lhs.true5.i ], [ 0, %while.cond.preheader.i ], [ 0, %if.end12.i ], [ 1, %while.body.i ]
76    %backToBool = trunc i64 %retval.0.i1 to i1
77    ret i1 %backToBool
78  }
79
80  attributes #0 = { "target-cpu"="pwr9" }
81
82...
83---
84name:            _ZN11xercesc_2_79HashXMLCh6equalsEPKvS2_
85alignment:       16
86exposesReturnsTwice: false
87legalized:       false
88regBankSelected: false
89selected:        false
90failedISel:      false
91tracksRegLiveness: true
92hasWinCFI:       false
93registers:       []
94liveins:
95  - { reg: '$x4', virtual-reg: '' }
96  - { reg: '$x5', virtual-reg: '' }
97frameInfo:
98  isFrameAddressTaken: false
99  isReturnAddressTaken: false
100  hasStackMap:     false
101  hasPatchPoint:   false
102  stackSize:       0
103  offsetAdjustment: 0
104  maxAlignment:    0
105  adjustsStack:    false
106  hasCalls:        false
107  stackProtector:  ''
108  maxCallFrameSize: 0
109  cvBytesOfCalleeSavedRegisters: 0
110  hasOpaqueSPAdjustment: false
111  hasVAStart:      false
112  hasMustTailInVarArgFunc: false
113  localFrameSize:  0
114  savePoint:       ''
115  restorePoint:    ''
116fixedStack:      []
117stack:           []
118callSites:       []
119constants:       []
120machineFunctionInfo: {}
121body:             |
122  bb.0.entry:
123    successors: %bb.5(0x40000000), %bb.1(0x40000000)
124    liveins: $x4, $x5
125
126    renamable $cr1 = CMPDI renamable $x4, 0
127    renamable $cr0 = CMPDI renamable $x5, 0
128    renamable $cr5lt = CROR renamable $cr1eq, renamable $cr0eq
129    BC killed renamable $cr5lt, %bb.5
130
131  bb.1.while.cond.preheader.i:
132    successors: %bb.2(0x40000000), %bb.11(0x40000000)
133    liveins: $x4, $x5
134
135    renamable $r8 = LHZ 0, renamable $x4 :: (load 2 from %ir.1)
136    renamable $r6 = LHZ 0, renamable $x5 :: (load 2 from %ir.0)
137    renamable $x3 = LI8 0
138    renamable $cr0 = CMPLW renamable $r8, killed renamable $r6
139    BCC 68, killed renamable $cr0, %bb.11
140
141  bb.2.while.body.i.preheader:
142    successors: %bb.3(0x80000000)
143    liveins: $r8, $x3, $x4, $x5
144
145    renamable $x6 = ADDI8 renamable $x5, 2
146    renamable $x7 = ADDI8 renamable $x4, 2
147
148  bb.3.while.body.i:
149    successors: %bb.4(0x04000000), %bb.10(0x7c000000)
150    liveins: $r8, $x3, $x4, $x5, $x6, $x7
151
152    dead renamable $r8 = ANDI_rec killed renamable $r8, 65535, implicit-def $cr0
153    BCC 68, killed renamable $cr0, %bb.10
154
155  bb.4:
156    renamable $x3 = LI8 1
157    BLR8 implicit $lr8, implicit $rm, implicit killed $x3
158
159  bb.5.if.then.i:
160    successors: %bb.7(0x30000000), %bb.6(0x50000000)
161    liveins: $cr0, $cr1, $x4, $x5
162
163    BC killed renamable $cr1eq, %bb.7
164
165  bb.6.land.lhs.true.i:
166    successors: %bb.7(0x30000000), %bb.11(0x50000000)
167    liveins: $cr0, $x4, $x5
168
169    renamable $r4 = LHZ 0, killed renamable $x4 :: (load 2 from %ir.4)
170    renamable $x3 = LI8 0
171    renamable $cr1 = CMPLWI killed renamable $r4, 0
172    BCC 68, killed renamable $cr1, %bb.11
173
174  bb.7.lor.lhs.false3.i:
175    successors: %bb.9(0x30000000), %bb.8(0x50000000)
176    liveins: $cr0, $x5
177
178    BC killed renamable $cr0eq, %bb.9
179
180  bb.8.land.lhs.true5.i:
181    successors: %bb.9(0x80000000)
182    liveins: $x5
183
184    renamable $r4 = LHZ 0, killed renamable $x5 :: (load 2 from %ir.6)
185    renamable $x3 = LI8 0
186    renamable $cr0 = CMPLWI killed renamable $r4, 0
187    BCCLR 68, killed renamable $cr0, implicit $lr, implicit $rm, implicit killed $x3
188
189  bb.9.if.else.i:
190    renamable $x3 = LI8 1
191    BLR8 implicit $lr8, implicit $rm, implicit killed $x3
192
193  bb.10.if.end12.i:
194    successors: %bb.3(0x7c000000), %bb.11(0x04000000)
195    liveins: $x3, $x4, $x5, $x6, $x7
196
197    renamable $x5 = ADDI8 killed renamable $x5, 2
198    renamable $x4 = ADDI8 killed renamable $x4, 2
199    renamable $r8 = LHZ 0, renamable $x4 :: (load 2 from %ir.14)
200    renamable $r9 = LHZ 0, renamable $x5 :: (load 2 from %ir.12)
201    renamable $x6 = ADDI8 killed renamable $x6, 2
202    renamable $x7 = ADDI8 killed renamable $x7, 2
203    renamable $cr0 = CMPLW renamable $r8, killed renamable $r9
204    BCC 76, killed renamable $cr0, %bb.3
205
206  bb.11._ZN11xercesc_2_79XMLString6equalsEPKtS2_.exit:
207    liveins: $x3
208
209    BLR8 implicit $lr8, implicit $rm, implicit killed $x3
210
211  ; CHECK:      bb.5.if.else.i:
212  ; CHECK:        successors: %bb.11(0x80000000)
213
214  ; CHECK:      bb.11:
215  ; CHECK:        renamable $x3 = LI8 1
216  ; CHECK-NEXT:   BLR8 implicit $lr8, implicit $rm, implicit killed $x3
217
218  ; CHECK:      bb.8.while.body.i (align 16):
219  ; CHECK:        successors: %bb.11(0x04000000), %bb.9(0x7c000000)
220  ; CHECK:        BCC 76, killed renamable $cr0, %bb.11
221...
222