1# RUN: llc -mtriple=hexagon -run-pass pipeliner -debug-only=pipeliner %s -o /dev/null 2>&1 -pipeliner-experimental-cg=true | FileCheck %s
2# REQUIRES: asserts
3
4# Test that the loop carried dependence check correctly identifies a recurrence
5# when the loop variable decreases and the array index offset is negative.
6
7# CHECK: Rec NodeSet
8# CHECK: Rec NodeSet
9# CHECK: SU(3)
10# CHECK: SU(4)
11# CHECK: SU(5)
12
13--- |
14
15  define void @test() {
16  b0:
17    br label %b3
18
19  b3:
20    %lsr.iv = phi [9 x i32]* [ %0, %b3 ], [ undef, %b0 ]
21    %v0 = phi i32 [ %v8, %b3 ], [ 7, %b0 ]
22    %v1 = phi i32 [ %v6, %b3 ], [ undef, %b0 ]
23    %v2 = phi i32 [ %v1, %b3 ], [ undef, %b0 ]
24    %lsr.iv1 = bitcast [9 x i32]* %lsr.iv to i32*
25    %cgep = getelementptr i32, i32* %lsr.iv1, i32 -2
26    %v6 = load i32, i32* %cgep, align 4
27    %v7 = tail call i32 @llvm.hexagon.A2.subsat(i32 %v2, i32 %v6)
28    store i32 %v7, i32* %lsr.iv1, align 4
29    %v8 = add i32 %v0, -1
30    %cgep3 = getelementptr [9 x i32], [9 x i32]* %lsr.iv, i32 0, i32 -1
31    %0 = bitcast i32* %cgep3 to [9 x i32]*
32    %v9 = icmp sgt i32 %v8, 1
33    br i1 %v9, label %b3, label %b4
34
35  b4:
36    unreachable
37  }
38
39  declare i32 @llvm.hexagon.A2.subsat(i32, i32) #0
40  declare void @llvm.stackprotector(i8*, i8**) #1
41
42...
43---
44name:            test
45tracksRegLiveness: true
46
47body:             |
48  bb.0:
49    successors: %bb.1
50
51    %10:intregs = IMPLICIT_DEF
52    %11:intregs = IMPLICIT_DEF
53    J2_loop0i %bb.1, 6, implicit-def $lc0, implicit-def $sa0, implicit-def $usr
54
55  bb.1 (address-taken):
56    successors: %bb.1, %bb.2
57
58    %0:intregs = PHI %11, %bb.0, %6, %bb.1
59    %2:intregs = PHI %10, %bb.0, %4, %bb.1
60    %3:intregs = PHI %10, %bb.0, %2, %bb.1
61    %4:intregs = L2_loadri_io %0, -8 :: (load 4 from %ir.cgep)
62    %12:intregs = A2_subsat %3, %4, implicit-def dead $usr_ovf
63    S2_storeri_io %0, 0, %12 :: (store 4 into %ir.lsr.iv1)
64    %6:intregs = A2_addi %0, -4
65    ENDLOOP0 %bb.1, implicit-def $pc, implicit-def $lc0, implicit $sa0, implicit $lc0
66    J2_jump %bb.2, implicit-def dead $pc
67
68  bb.2:
69
70...
71