# RUN: llc -mtriple=powerpc64le-linux-gnu -stop-after ppc-pre-emit-peephole %s -o - -verify-machineinstrs | FileCheck %s
---
name: test1
# The cmp instr is optimized with the record form.
tracksRegLiveness: true
body: |
bb.0.entry:
successors: %bb.1(0x30000000), %bb.2(0x50000000)
liveins: $x3, $x4
renamable $x3 = OR8 killed renamable $x3, killed renamable $x4
renamable $cr0 = CMPDI renamable $x3, 0, implicit killed $x3
; CHECK-LABEL: name: test1
; CHECK: renamable $x3 = OR8_rec killed renamable $x3, killed renamable $x4, implicit-def $cr0
; CHECK-NOT: CMPDI
BCC 68, killed renamable $cr0, %bb.2
bb.1:
$x3 = LI8 102
BLR8 implicit $lr8, implicit $rm, implicit $x3
bb.2:
$x3 = LI8 116
BLR8 implicit $lr8, implicit $rm, implicit $x3
...
---
name: test2
# The imm of the comparison instr isn't 0.
tracksRegLiveness: true
body: |
bb.0.entry:
successors: %bb.1(0x30000000), %bb.2(0x50000000)
liveins: $x3, $x4
renamable $x3 = OR8 killed renamable $x3, killed renamable $x4
renamable $cr0 = CMPDI renamable $x3, 2, implicit killed $x3
; CHECK-LABEL: name: test2
; CHECK: CMPDI
BCC 68, killed renamable $cr0, %bb.2
bb.1:
$x3 = LI8 102
BLR8 implicit $lr8, implicit $rm, implicit $x3
bb.2:
$x3 = LI8 116
BLR8 implicit $lr8, implicit $rm, implicit $x3
...
---
name: test3
# The comparison instr has a implicit def.
tracksRegLiveness: true
body: |
bb.0.entry:
successors: %bb.1(0x30000000), %bb.2(0x50000000)
liveins: $x3, $x4
renamable $x3 = OR8 killed renamable $x3, killed renamable $x4
renamable $cr0 = CMPDI renamable $x3, 0, implicit-def $x3
; CHECK-LABEL: name: test3
; CHECK: CMPDI
BCC 68, killed renamable $cr0, %bb.2
bb.1:
$x3 = LI8 102
BLR8 implicit $lr8, implicit $rm, implicit $x3
bb.2:
$x3 = LI8 116
BLR8 implicit $lr8, implicit $rm, implicit $x3
...
---
name: test4
# There is another use for cr0 between OR8 instr and CMPWI instr.
tracksRegLiveness: true
body: |
bb.0.entry:
successors: %bb.1(0x30000000), %bb.2(0x50000000)
liveins: $x3, $x4, $cr0
renamable $x3 = OR8 killed renamable $x3, killed renamable $x4
renamable $cr1 = MCRF killed $cr0, implicit $x3
renamable $cr0 = CMPDI renamable $x3, 0, implicit killed $x3, implicit $cr1
; CHECK-LABEL: name: test4
; CHECK: CMPDI
BCC 68, killed renamable $cr0, %bb.2
bb.1:
$x3 = LI8 102
BLR8 implicit $lr8, implicit $rm, implicit $x3
bb.2:
$x3 = LI8 116
BLR8 implicit $lr8, implicit $rm, implicit $x3
...
---
name: test5
# There is another def for cr0 between OR8 instr and CMPWI instr.
tracksRegLiveness: true
body: |
bb.0.entry:
successors: %bb.1(0x30000000), %bb.2(0x50000000)
liveins: $x3, $x4
renamable $x3 = OR8 killed renamable $x3, renamable $x4
renamable $cr1 = CMPD renamable $x3, renamable $x4, implicit-def $cr0
renamable $cr0 = CMPDI renamable $x3, 0, implicit killed $x3, implicit $cr1
; CHECK-LABEL: name: test5
; CHECK: CMPDI
BCC 68, killed renamable $cr0, %bb.2
bb.1:
$x3 = LI8 102
BLR8 implicit $lr8, implicit $rm, implicit $x3
bb.2:
$x3 = LI8 116
BLR8 implicit $lr8, implicit $rm, implicit $x3
...
---
name: test6
# The SrcReg isn't CR0.
tracksRegLiveness: true
body: |
bb.0.entry:
successors: %bb.1(0x30000000), %bb.2(0x50000000)
liveins: $x3, $x4
renamable $x3 = OR8 killed renamable $x3, killed renamable $x4
renamable $cr1 = CMPDI renamable $x3, 0, implicit killed $x3
; CHECK-LABEL: name: test6
; CHECK: CMPDI
BCC 68, killed renamable $cr1, %bb.2
bb.1:
$x3 = LI8 102
BLR8 implicit $lr8, implicit $rm, implicit $x3
bb.2:
$x3 = LI8 116
BLR8 implicit $lr8, implicit $rm, implicit $x3
...