llvm/llvm/test/CodeGen/Thumb2/LowOverheadLoops/no-dec-cbnz.mir

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple=thumbv8.1m.main %s -run-pass=arm-cp-islands --verify-machineinstrs -o - | FileCheck %s --check-prefix=CHECK-LOB
# RUN: llc -mtriple=thumbv8.1m.main -mattr=-lob %s -run-pass=arm-cp-islands --verify-machineinstrs -o - | FileCheck %s --check-prefix=CHECK-NOLOB

--- |
  %struct.head_s = type { ptr, ptr }
  %struct.data_s = type { i16, i16 }

  define dso_local arm_aapcscc ptr @search(ptr readonly %list, ptr nocapture readonly %info) local_unnamed_addr {
  entry:
    %idx = getelementptr inbounds %struct.data_s, ptr %info, i32 0, i32 1
    %0 = load i16, ptr %idx, align 2
    %cmp = icmp sgt i16 %0, -1
    br i1 %cmp, label %while.cond.preheader, label %while.cond9.preheader

  while.cond9.preheader:                            ; preds = %entry
    %1 = icmp eq ptr %list, null
    br i1 %1, label %return, label %land.rhs11.lr.ph

  land.rhs11.lr.ph:                                 ; preds = %while.cond9.preheader
    %data16143 = bitcast ptr %info to ptr
    %2 = load i16, ptr %data16143, align 2
    %conv15 = sext i16 %2 to i32
    br label %land.rhs11

  while.cond.preheader:                             ; preds = %entry
    %3 = icmp eq ptr %list, null
    br i1 %3, label %return, label %land.rhs.preheader

  land.rhs.preheader:                               ; preds = %while.cond.preheader
    br label %land.rhs

  land.rhs:                                         ; preds = %land.rhs.preheader, %while.body
    %list.addr.033 = phi ptr [ %6, %while.body ], [ %list, %land.rhs.preheader ]
    %info2 = getelementptr inbounds %struct.head_s, ptr %list.addr.033, i32 0, i32 1
    %4 = load ptr, ptr %info2, align 4
    %idx3 = getelementptr inbounds %struct.data_s, ptr %4, i32 0, i32 1
    %5 = load i16, ptr %idx3, align 2
    %cmp7 = icmp eq i16 %5, %0
    br i1 %cmp7, label %return, label %while.body

  while.body:                                       ; preds = %land.rhs
    %next4 = bitcast ptr %list.addr.033 to ptr
    %6 = load ptr, ptr %next4, align 4
    %tobool = icmp ne ptr %6, null
    br i1 %tobool, label %return, label %land.rhs

  land.rhs11:                                       ; preds = %while.body19, %land.rhs11.lr.ph
    %list.addr.136 = phi ptr [ %list, %land.rhs11.lr.ph ], [ %10, %while.body19 ]
    %info12 = getelementptr inbounds %struct.head_s, ptr %list.addr.136, i32 0, i32 1
    %7 = load ptr, ptr %info12, align 4
    %data165 = bitcast ptr %7 to ptr
    %8 = load i16, ptr %data165, align 2
    %9 = and i16 %8, 255
    %and = zext i16 %9 to i32
    %cmp16 = icmp eq i32 %and, %conv15
    br i1 %cmp16, label %return, label %while.body19

  while.body19:                                     ; preds = %land.rhs11
    %next206 = bitcast ptr %list.addr.136 to ptr
    %10 = load ptr, ptr %next206, align 4
    %tobool10 = icmp eq ptr %10, null
    br i1 %tobool10, label %return, label %land.rhs11

  return:                                           ; preds = %while.body19, %land.rhs11, %while.body, %land.rhs, %while.cond.preheader, %while.cond9.preheader
    %retval.0 = phi ptr [ null, %while.cond.preheader ], [ null, %while.cond9.preheader ], [ null, %while.body ], [ %list.addr.033, %land.rhs ], [ null, %while.body19 ], [ %list.addr.136, %land.rhs11 ]
    ret ptr %retval.0
  }

...
---
name:            search
alignment:       2
exposesReturnsTwice: false
legalized:       false
regBankSelected: false
selected:        false
failedISel:      false
tracksRegLiveness: true
hasWinCFI:       false
registers:       []
liveins:
  - { reg: '$r0', virtual-reg: '' }
  - { reg: '$r1', virtual-reg: '' }
frameInfo:
  isFrameAddressTaken: false
  isReturnAddressTaken: false
  hasStackMap:     false
  hasPatchPoint:   false
  stackSize:       0
  offsetAdjustment: 0
  maxAlignment:    1
  adjustsStack:    false
  hasCalls:        false
  stackProtector:  ''
  maxCallFrameSize: 0
  cvBytesOfCalleeSavedRegisters: 0
  hasOpaqueSPAdjustment: false
  hasVAStart:      false
  hasMustTailInVarArgFunc: false
  localFrameSize:  0
  savePoint:       ''
  restorePoint:    ''
fixedStack:      []
stack:           []
callSites:       []
constants:       []
machineFunctionInfo: {}
body:             |
  ; CHECK-LOB-LABEL: name: search
  ; CHECK-LOB: bb.0.entry:
  ; CHECK-LOB-NEXT:   successors: %bb.1(0x50000000), %bb.5(0x30000000)
  ; CHECK-LOB-NEXT:   liveins: $r0, $r1
  ; CHECK-LOB-NEXT: {{  $}}
  ; CHECK-LOB-NEXT:   renamable $r2 = t2LDRSHi12 renamable $r1, 2, 14 /* CC::al */, $noreg :: (load (s16) from %ir.idx)
  ; CHECK-LOB-NEXT:   t2CMPri renamable $r2, -1, 14 /* CC::al */, $noreg, implicit-def $cpsr
  ; CHECK-LOB-NEXT:   tBcc %bb.5, 13 /* CC::le */, killed $cpsr
  ; CHECK-LOB-NEXT: {{  $}}
  ; CHECK-LOB-NEXT: bb.1.while.cond.preheader:
  ; CHECK-LOB-NEXT:   successors: %bb.9(0x30000000), %bb.2(0x50000000)
  ; CHECK-LOB-NEXT:   liveins: $r0, $r2
  ; CHECK-LOB-NEXT: {{  $}}
  ; CHECK-LOB-NEXT:   tCBZ renamable $r0, %bb.9
  ; CHECK-LOB-NEXT: {{  $}}
  ; CHECK-LOB-NEXT: bb.2.land.rhs.preheader:
  ; CHECK-LOB-NEXT:   successors: %bb.3(0x80000000)
  ; CHECK-LOB-NEXT:   liveins: $r0, $r2
  ; CHECK-LOB-NEXT: {{  $}}
  ; CHECK-LOB-NEXT:   renamable $r1 = tUXTH killed renamable $r2, 14 /* CC::al */, $noreg
  ; CHECK-LOB-NEXT: {{  $}}
  ; CHECK-LOB-NEXT: bb.3.land.rhs:
  ; CHECK-LOB-NEXT:   successors: %bb.4(0x80000000)
  ; CHECK-LOB-NEXT:   liveins: $r0, $r1
  ; CHECK-LOB-NEXT: {{  $}}
  ; CHECK-LOB-NEXT:   renamable $r2 = tLDRi renamable $r0, 1, 14 /* CC::al */, $noreg :: (load (s32) from %ir.info2)
  ; CHECK-LOB-NEXT:   renamable $r2 = tLDRHi killed renamable $r2, 1, 14 /* CC::al */, $noreg :: (load (s16) from %ir.idx3)
  ; CHECK-LOB-NEXT:   tCMPr killed renamable $r2, renamable $r1, 14 /* CC::al */, $noreg, implicit-def $cpsr
  ; CHECK-LOB-NEXT:   t2IT 0, 8, implicit-def $itstate
  ; CHECK-LOB-NEXT:   tBX_RET 0 /* CC::eq */, killed $cpsr, implicit $r0, implicit killed $itstate
  ; CHECK-LOB-NEXT: {{  $}}
  ; CHECK-LOB-NEXT: bb.4.while.body:
  ; CHECK-LOB-NEXT:   successors: %bb.9(0x04000000), %bb.3(0x7c000000)
  ; CHECK-LOB-NEXT:   liveins: $r0, $r1
  ; CHECK-LOB-NEXT: {{  $}}
  ; CHECK-LOB-NEXT:   renamable $r0 = tLDRi killed renamable $r0, 0, 14 /* CC::al */, $noreg :: (load (s32) from %ir.next4)
  ; CHECK-LOB-NEXT:   tCBNZ renamable $r0, %bb.9
  ; CHECK-LOB-NEXT:   t2LE %bb.3
  ; CHECK-LOB-NEXT: {{  $}}
  ; CHECK-LOB-NEXT: bb.5.while.cond9.preheader:
  ; CHECK-LOB-NEXT:   successors: %bb.9(0x30000000), %bb.6(0x50000000)
  ; CHECK-LOB-NEXT:   liveins: $r0, $r1
  ; CHECK-LOB-NEXT: {{  $}}
  ; CHECK-LOB-NEXT:   tCBZ renamable $r0, %bb.9
  ; CHECK-LOB-NEXT: {{  $}}
  ; CHECK-LOB-NEXT: bb.6.land.rhs11.lr.ph:
  ; CHECK-LOB-NEXT:   successors: %bb.7(0x80000000)
  ; CHECK-LOB-NEXT:   liveins: $r0, $r1
  ; CHECK-LOB-NEXT: {{  $}}
  ; CHECK-LOB-NEXT:   renamable $r1 = t2LDRSHi12 killed renamable $r1, 0, 14 /* CC::al */, $noreg :: (load (s16) from %ir.data16143)
  ; CHECK-LOB-NEXT: {{  $}}
  ; CHECK-LOB-NEXT: bb.7.land.rhs11:
  ; CHECK-LOB-NEXT:   successors: %bb.10(0x04000000), %bb.8(0x7c000000)
  ; CHECK-LOB-NEXT:   liveins: $r0, $r1
  ; CHECK-LOB-NEXT: {{  $}}
  ; CHECK-LOB-NEXT:   renamable $r2 = tLDRi renamable $r0, 1, 14 /* CC::al */, $noreg :: (load (s32) from %ir.info12)
  ; CHECK-LOB-NEXT:   renamable $r2 = tLDRBi killed renamable $r2, 0, 14 /* CC::al */, $noreg :: (load (s8) from %ir.data165, align 2)
  ; CHECK-LOB-NEXT:   tCMPr killed renamable $r2, renamable $r1, 14 /* CC::al */, $noreg, implicit-def $cpsr
  ; CHECK-LOB-NEXT:   tBcc %bb.10, 0 /* CC::eq */, killed $cpsr
  ; CHECK-LOB-NEXT: {{  $}}
  ; CHECK-LOB-NEXT: bb.8.while.body19:
  ; CHECK-LOB-NEXT:   successors: %bb.9(0x04000000), %bb.7(0x7c000000)
  ; CHECK-LOB-NEXT:   liveins: $r0, $r1
  ; CHECK-LOB-NEXT: {{  $}}
  ; CHECK-LOB-NEXT:   renamable $r0 = tLDRi killed renamable $r0, 0, 14 /* CC::al */, $noreg :: (load (s32) from %ir.next206)
  ; CHECK-LOB-NEXT:   tCBZ renamable $r0, %bb.9
  ; CHECK-LOB-NEXT:   t2LE %bb.7
  ; CHECK-LOB-NEXT: {{  $}}
  ; CHECK-LOB-NEXT: bb.9:
  ; CHECK-LOB-NEXT:   successors: %bb.10(0x80000000)
  ; CHECK-LOB-NEXT: {{  $}}
  ; CHECK-LOB-NEXT:   renamable $r0, dead $cpsr = tMOVi8 0, 14 /* CC::al */, $noreg
  ; CHECK-LOB-NEXT: {{  $}}
  ; CHECK-LOB-NEXT: bb.10.return:
  ; CHECK-LOB-NEXT:   liveins: $r0
  ; CHECK-LOB-NEXT: {{  $}}
  ; CHECK-LOB-NEXT:   tBX_RET 14 /* CC::al */, $noreg, implicit killed $r0
  ;
  ; CHECK-NOLOB-LABEL: name: search
  ; CHECK-NOLOB: bb.0.entry:
  ; CHECK-NOLOB-NEXT:   successors: %bb.1(0x50000000), %bb.5(0x30000000)
  ; CHECK-NOLOB-NEXT:   liveins: $r0, $r1
  ; CHECK-NOLOB-NEXT: {{  $}}
  ; CHECK-NOLOB-NEXT:   renamable $r2 = t2LDRSHi12 renamable $r1, 2, 14 /* CC::al */, $noreg :: (load (s16) from %ir.idx)
  ; CHECK-NOLOB-NEXT:   t2CMPri renamable $r2, -1, 14 /* CC::al */, $noreg, implicit-def $cpsr
  ; CHECK-NOLOB-NEXT:   tBcc %bb.5, 13 /* CC::le */, killed $cpsr
  ; CHECK-NOLOB-NEXT: {{  $}}
  ; CHECK-NOLOB-NEXT: bb.1.while.cond.preheader:
  ; CHECK-NOLOB-NEXT:   successors: %bb.9(0x30000000), %bb.2(0x50000000)
  ; CHECK-NOLOB-NEXT:   liveins: $r0, $r2
  ; CHECK-NOLOB-NEXT: {{  $}}
  ; CHECK-NOLOB-NEXT:   tCBZ renamable $r0, %bb.9
  ; CHECK-NOLOB-NEXT: {{  $}}
  ; CHECK-NOLOB-NEXT: bb.2.land.rhs.preheader:
  ; CHECK-NOLOB-NEXT:   successors: %bb.3(0x80000000)
  ; CHECK-NOLOB-NEXT:   liveins: $r0, $r2
  ; CHECK-NOLOB-NEXT: {{  $}}
  ; CHECK-NOLOB-NEXT:   renamable $r1 = tUXTH killed renamable $r2, 14 /* CC::al */, $noreg
  ; CHECK-NOLOB-NEXT: {{  $}}
  ; CHECK-NOLOB-NEXT: bb.3.land.rhs:
  ; CHECK-NOLOB-NEXT:   successors: %bb.4(0x80000000)
  ; CHECK-NOLOB-NEXT:   liveins: $r0, $r1
  ; CHECK-NOLOB-NEXT: {{  $}}
  ; CHECK-NOLOB-NEXT:   renamable $r2 = tLDRi renamable $r0, 1, 14 /* CC::al */, $noreg :: (load (s32) from %ir.info2)
  ; CHECK-NOLOB-NEXT:   renamable $r2 = tLDRHi killed renamable $r2, 1, 14 /* CC::al */, $noreg :: (load (s16) from %ir.idx3)
  ; CHECK-NOLOB-NEXT:   tCMPr killed renamable $r2, renamable $r1, 14 /* CC::al */, $noreg, implicit-def $cpsr
  ; CHECK-NOLOB-NEXT:   t2IT 0, 8, implicit-def $itstate
  ; CHECK-NOLOB-NEXT:   tBX_RET 0 /* CC::eq */, killed $cpsr, implicit $r0, implicit killed $itstate
  ; CHECK-NOLOB-NEXT: {{  $}}
  ; CHECK-NOLOB-NEXT: bb.4.while.body:
  ; CHECK-NOLOB-NEXT:   successors: %bb.9(0x04000000), %bb.3(0x7c000000)
  ; CHECK-NOLOB-NEXT:   liveins: $r0, $r1
  ; CHECK-NOLOB-NEXT: {{  $}}
  ; CHECK-NOLOB-NEXT:   renamable $r0 = tLDRi killed renamable $r0, 0, 14 /* CC::al */, $noreg :: (load (s32) from %ir.next4)
  ; CHECK-NOLOB-NEXT:   tCMPi8 renamable $r0, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr
  ; CHECK-NOLOB-NEXT:   tBcc %bb.3, 0 /* CC::eq */, killed $cpsr
  ; CHECK-NOLOB-NEXT:   tB %bb.9, 14 /* CC::al */, $noreg
  ; CHECK-NOLOB-NEXT: {{  $}}
  ; CHECK-NOLOB-NEXT: bb.5.while.cond9.preheader:
  ; CHECK-NOLOB-NEXT:   successors: %bb.9(0x30000000), %bb.6(0x50000000)
  ; CHECK-NOLOB-NEXT:   liveins: $r0, $r1
  ; CHECK-NOLOB-NEXT: {{  $}}
  ; CHECK-NOLOB-NEXT:   tCBZ renamable $r0, %bb.9
  ; CHECK-NOLOB-NEXT: {{  $}}
  ; CHECK-NOLOB-NEXT: bb.6.land.rhs11.lr.ph:
  ; CHECK-NOLOB-NEXT:   successors: %bb.7(0x80000000)
  ; CHECK-NOLOB-NEXT:   liveins: $r0, $r1
  ; CHECK-NOLOB-NEXT: {{  $}}
  ; CHECK-NOLOB-NEXT:   renamable $r1 = t2LDRSHi12 killed renamable $r1, 0, 14 /* CC::al */, $noreg :: (load (s16) from %ir.data16143)
  ; CHECK-NOLOB-NEXT: {{  $}}
  ; CHECK-NOLOB-NEXT: bb.7.land.rhs11:
  ; CHECK-NOLOB-NEXT:   successors: %bb.10(0x04000000), %bb.8(0x7c000000)
  ; CHECK-NOLOB-NEXT:   liveins: $r0, $r1
  ; CHECK-NOLOB-NEXT: {{  $}}
  ; CHECK-NOLOB-NEXT:   renamable $r2 = tLDRi renamable $r0, 1, 14 /* CC::al */, $noreg :: (load (s32) from %ir.info12)
  ; CHECK-NOLOB-NEXT:   renamable $r2 = tLDRBi killed renamable $r2, 0, 14 /* CC::al */, $noreg :: (load (s8) from %ir.data165, align 2)
  ; CHECK-NOLOB-NEXT:   tCMPr killed renamable $r2, renamable $r1, 14 /* CC::al */, $noreg, implicit-def $cpsr
  ; CHECK-NOLOB-NEXT:   tBcc %bb.10, 0 /* CC::eq */, killed $cpsr
  ; CHECK-NOLOB-NEXT: {{  $}}
  ; CHECK-NOLOB-NEXT: bb.8.while.body19:
  ; CHECK-NOLOB-NEXT:   successors: %bb.9(0x04000000), %bb.7(0x7c000000)
  ; CHECK-NOLOB-NEXT:   liveins: $r0, $r1
  ; CHECK-NOLOB-NEXT: {{  $}}
  ; CHECK-NOLOB-NEXT:   renamable $r0 = tLDRi killed renamable $r0, 0, 14 /* CC::al */, $noreg :: (load (s32) from %ir.next206)
  ; CHECK-NOLOB-NEXT:   tCMPi8 renamable $r0, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr
  ; CHECK-NOLOB-NEXT:   tBcc %bb.7, 1 /* CC::ne */, killed $cpsr
  ; CHECK-NOLOB-NEXT: {{  $}}
  ; CHECK-NOLOB-NEXT: bb.9:
  ; CHECK-NOLOB-NEXT:   successors: %bb.10(0x80000000)
  ; CHECK-NOLOB-NEXT: {{  $}}
  ; CHECK-NOLOB-NEXT:   renamable $r0, dead $cpsr = tMOVi8 0, 14 /* CC::al */, $noreg
  ; CHECK-NOLOB-NEXT: {{  $}}
  ; CHECK-NOLOB-NEXT: bb.10.return:
  ; CHECK-NOLOB-NEXT:   liveins: $r0
  ; CHECK-NOLOB-NEXT: {{  $}}
  ; CHECK-NOLOB-NEXT:   tBX_RET 14 /* CC::al */, $noreg, implicit killed $r0
  bb.0.entry:
    successors: %bb.5(0x50000000), %bb.1(0x30000000)
    liveins: $r0, $r1

    renamable $r2 = t2LDRSHi12 renamable $r1, 2, 14 /* CC::al */, $noreg :: (load (s16) from %ir.idx)
    t2CMPri renamable $r2, -1, 14 /* CC::al */, $noreg, implicit-def $cpsr
    t2Bcc %bb.1, 13 /* CC::le */, killed $cpsr

  bb.5.while.cond.preheader:
    successors: %bb.9(0x30000000), %bb.6(0x50000000)
    liveins: $r0, $r2

    tCMPi8 renamable $r0, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr
    t2Bcc %bb.9, 0 /* CC::eq */, killed $cpsr

  bb.6.land.rhs.preheader:
    successors: %bb.7(0x80000000)
    liveins: $r0, $r2

    renamable $r1 = tUXTH killed renamable $r2, 14 /* CC::al */, $noreg

  bb.7.land.rhs:
    successors: %bb.8(0x80000000)
    liveins: $r0, $r1

    renamable $r2 = tLDRi renamable $r0, 1, 14 /* CC::al */, $noreg :: (load (s32) from %ir.info2)
    renamable $r2 = tLDRHi killed renamable $r2, 1, 14 /* CC::al */, $noreg :: (load (s16) from %ir.idx3)
    tCMPr killed renamable $r2, renamable $r1, 14 /* CC::al */, $noreg, implicit-def $cpsr
    t2IT 0, 8, implicit-def $itstate
    tBX_RET 0 /* CC::eq */, killed $cpsr, implicit $r0, implicit killed $itstate

  bb.8.while.body:
    successors: %bb.9(0x04000000), %bb.7(0x7c000000)
    liveins: $r0, $r1

    renamable $r0 = tLDRi killed renamable $r0, 0, 14 /* CC::al */, $noreg :: (load (s32) from %ir.next4)
    tCMPi8 renamable $r0, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr
    t2Bcc %bb.7, 0 /* CC::eq */, killed $cpsr
    t2B %bb.9, 14 /* CC::al */, $noreg

  bb.1.while.cond9.preheader:
    successors: %bb.9(0x30000000), %bb.2(0x50000000)
    liveins: $r0, $r1

    tCMPi8 renamable $r0, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr
    t2Bcc %bb.9, 0 /* CC::eq */, killed $cpsr

  bb.2.land.rhs11.lr.ph:
    successors: %bb.3(0x80000000)
    liveins: $r0, $r1

    renamable $r1 = t2LDRSHi12 killed renamable $r1, 0, 14 /* CC::al */, $noreg :: (load (s16) from %ir.data16143)

  bb.3.land.rhs11:
    successors: %bb.10(0x04000000), %bb.4(0x7c000000)
    liveins: $r0, $r1

    renamable $r2 = tLDRi renamable $r0, 1, 14 /* CC::al */, $noreg :: (load (s32) from %ir.info12)
    renamable $r2 = tLDRBi killed renamable $r2, 0, 14 /* CC::al */, $noreg :: (load (s8) from %ir.data165, align 2)
    tCMPr killed renamable $r2, renamable $r1, 14 /* CC::al */, $noreg, implicit-def $cpsr
    t2Bcc %bb.10, 0 /* CC::eq */, killed $cpsr

  bb.4.while.body19:
    successors: %bb.9(0x04000000), %bb.3(0x7c000000)
    liveins: $r0, $r1

    renamable $r0 = tLDRi killed renamable $r0, 0, 14 /* CC::al */, $noreg :: (load (s32) from %ir.next206)
    tCMPi8 renamable $r0, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr
    t2Bcc %bb.3, 1 /* CC::ne */, killed $cpsr

  bb.9:
    successors: %bb.10(0x80000000)

    renamable $r0, dead $cpsr = tMOVi8 0, 14 /* CC::al */, $noreg

  bb.10.return:
    liveins: $r0

    tBX_RET 14 /* CC::al */, $noreg, implicit killed $r0

...