xref: /aosp_15_r20/external/llvm/test/CodeGen/Hexagon/hwloop-wrap.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=hexagon -mcpu=hexagonv5 < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; We shouldn't generate a hardware loop in this case because the initial
4*9880d681SAndroid Build Coastguard Worker; value may be zero, which means the endloop instruction will not decrement
5*9880d681SAndroid Build Coastguard Worker; the loop counter, and the loop will execute only once.
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: loop0
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Workerdefine void @foo(i32 %count, i32 %v) #0 {
10*9880d681SAndroid Build Coastguard Workerentry:
11*9880d681SAndroid Build Coastguard Worker  br label %do.body
12*9880d681SAndroid Build Coastguard Worker
13*9880d681SAndroid Build Coastguard Workerdo.body:
14*9880d681SAndroid Build Coastguard Worker  %count.addr.0 = phi i32 [ %count, %entry ], [ %dec, %do.body ]
15*9880d681SAndroid Build Coastguard Worker  tail call void asm sideeffect "nop", ""() #1
16*9880d681SAndroid Build Coastguard Worker  %dec = add i32 %count.addr.0, -1
17*9880d681SAndroid Build Coastguard Worker  %cmp = icmp eq i32 %dec, 0
18*9880d681SAndroid Build Coastguard Worker  br i1 %cmp, label %do.end, label %do.body
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Workerdo.end:
21*9880d681SAndroid Build Coastguard Worker  ret void
22*9880d681SAndroid Build Coastguard Worker}
23