1# RUN: llc -march=hexagon -run-pass hwloops %s -o - | FileCheck %s
2
3# Normally, if the registers holding the induction variable's bounds
4# are redefined inside of the loop's body, the loop cannot be converted
5# to a hardware loop. However, if the redefining instruction is actually
6# loading an immediate value into the register, this conversion is both
7# possible and legal (since the immediate itself will be used in the
8# loop setup in the preheader).
9
10# CHECK:  [[R0:%[0-9]+]]:intregs = A2_tfrsi 1920
11# CHECK:  J2_loop0r %bb.1, [[R0]]
12#
13# CHECK: bb.1.b1 (address-taken):
14# CHECK:   ENDLOOP0 %bb.1
15
16
17--- |
18  define void @fred() {
19  b0:
20    br label %b1
21  b1:
22    br label %b2
23  b2:
24    ret void
25  }
26...
27
28---
29name: fred
30tracksRegLiveness: true
31registers:
32  - { id: 0, class: intregs }
33  - { id: 1, class: intregs }
34  - { id: 2, class: intregs }
35  - { id: 3, class: intregs }
36  - { id: 4, class: intregs }
37  - { id: 5, class: intregs }
38  - { id: 6, class: intregs }
39  - { id: 7, class: intregs }
40  - { id: 8, class: predregs }
41body: |
42  bb.0.b0:
43    liveins: $r0
44    successors: %bb.1
45    %0 = A2_tfrsi 0
46    %1 = A2_tfrsi 0
47    %2 = COPY $r0
48
49  bb.1.b1:
50    successors: %bb.1, %bb.2
51    %3 = PHI %0, %bb.0, %6, %bb.1
52    %4 = PHI %1, %bb.0, %5, %bb.1
53    S4_storerh_rr %2, %4, 0, %3
54    %5 = A2_addi %4, 2
55    %6 = A2_addi %3, 1
56    ; This definition of %7 should not prevent conversion to hardware loop.
57    %7 = A2_tfrsi 3840
58    %8 = C2_cmpeq %5, %7
59    J2_jumpf %8, %bb.1, implicit-def $pc
60    J2_jump %bb.2, implicit-def $pc
61
62  bb.2.b2:
63...
64