1 ; RUN: opt < %s -S -mtriple=amdgcn-- -passes=loop-unroll | FileCheck %s
3 ; Check that the loop in unroll_default is not fully unrolled using the default
5 ; CHECK-LABEL: @unroll_default
10 ; Check that the same loop in unroll_full is fully unrolled when the default
11 ; unroll threshold is increased by use of the amdgpu-unroll-threshold attribute
12 ; CHECK-LABEL: @unroll_full
14 ; CHECK-NOT: br i1 %cmp
17 @in = internal unnamed_addr global ptr null, align 8
18 @out = internal unnamed_addr global ptr null, align 8
20 define void @unroll_default() {
24 do.body: ; preds = %entry
25 %i.0 = phi i32 [ 0, %entry ], [ %inc, %do.body ]
26 %v1 = load i64, ptr @in, align 8
27 store i64 %v1, ptr @out, align 8
28 %inc = add nsw i32 %i.0, 1
29 %cmp = icmp slt i32 %inc, 100
30 br i1 %cmp, label %do.body, label %do.end
32 do.end: ; preds = %do.body
36 define void @unroll_full() #0 {
40 do.body: ; preds = %entry
41 %i.0 = phi i32 [ 0, %entry ], [ %inc, %do.body ]
42 %v1 = load i64, ptr @in, align 8
43 store i64 %v1, ptr @out, align 8
44 %inc = add nsw i32 %i.0, 1
45 %cmp = icmp slt i32 %inc, 100
46 br i1 %cmp, label %do.body, label %do.end
48 do.end: ; preds = %do.body
52 attributes #0 = { "amdgpu-unroll-threshold"="1000" }