swp-carried-dep2.mir 2 KB
# RUN: llc -mtriple=hexagon -run-pass pipeliner -debug-only=pipeliner %s -o /dev/null 2>&1 -pipeliner-experimental-cg=true | FileCheck %s
# REQUIRES: asserts

# Test that the loop carried dependence check correctly identifies a recurrence
# when the loop variable decreases and the array index offset is negative.

# CHECK: Rec NodeSet
# CHECK: Rec NodeSet
# CHECK: SU(3)
# CHECK: SU(4)
# CHECK: SU(5)

--- |
  
  define void @test() {
  b0:
    br label %b3
  
  b3:
    %lsr.iv = phi [9 x i32]* [ %0, %b3 ], [ undef, %b0 ]
    %v0 = phi i32 [ %v8, %b3 ], [ 7, %b0 ]
    %v1 = phi i32 [ %v6, %b3 ], [ undef, %b0 ]
    %v2 = phi i32 [ %v1, %b3 ], [ undef, %b0 ]
    %lsr.iv1 = bitcast [9 x i32]* %lsr.iv to i32*
    %cgep = getelementptr i32, i32* %lsr.iv1, i32 -2
    %v6 = load i32, i32* %cgep, align 4
    %v7 = tail call i32 @llvm.hexagon.A2.subsat(i32 %v2, i32 %v6)
    store i32 %v7, i32* %lsr.iv1, align 4
    %v8 = add i32 %v0, -1
    %cgep3 = getelementptr [9 x i32], [9 x i32]* %lsr.iv, i32 0, i32 -1
    %0 = bitcast i32* %cgep3 to [9 x i32]*
    %v9 = icmp sgt i32 %v8, 1
    br i1 %v9, label %b3, label %b4
  
  b4:
    unreachable
  }
  
  declare i32 @llvm.hexagon.A2.subsat(i32, i32) #0
  declare void @llvm.stackprotector(i8*, i8**) #1

...
---
name:            test
tracksRegLiveness: true

body:             |
  bb.0:
    successors: %bb.1
  
    %10:intregs = IMPLICIT_DEF
    %11:intregs = IMPLICIT_DEF
    J2_loop0i %bb.1, 6, implicit-def $lc0, implicit-def $sa0, implicit-def $usr
  
  bb.1 (address-taken):
    successors: %bb.1, %bb.2
  
    %0:intregs = PHI %11, %bb.0, %6, %bb.1
    %2:intregs = PHI %10, %bb.0, %4, %bb.1
    %3:intregs = PHI %10, %bb.0, %2, %bb.1
    %4:intregs = L2_loadri_io %0, -8 :: (load 4 from %ir.cgep)
    %12:intregs = A2_subsat %3, %4, implicit-def dead $usr_ovf
    S2_storeri_io %0, 0, %12 :: (store 4 into %ir.lsr.iv1)
    %6:intregs = A2_addi %0, -4
    ENDLOOP0 %bb.1, implicit-def $pc, implicit-def $lc0, implicit $sa0, implicit $lc0
    J2_jump %bb.2, implicit-def dead $pc
  
  bb.2:

...