[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / llvm / test / Transforms / LoopUnroll / AMDGPU / unroll-threshold.ll
blobffc0ae9ae52bb47d3181b658632483be6cef7a51
1 ; RUN: opt < %s -S -mtriple=amdgcn-- -passes=loop-unroll | FileCheck %s
3 ; Check the handling of amdgpu.loop.unroll.threshold metadata which can be used to
4 ; set the default threshold for a loop. This metadata overrides both the AMDGPU
5 ; default, and any value specified by the amdgpu-unroll-threshold function attribute
6 ; (which sets a threshold for all loops in the function).
8 ; Check that the loop in unroll_default is not fully unrolled using the default
9 ; unroll threshold
10 ; CHECK-LABEL: @unroll_default
11 ; CHECK: entry:
12 ; CHECK: br i1 %cmp
13 ; CHECK: ret void
15 @in = internal unnamed_addr global ptr null, align 8
16 @out = internal unnamed_addr global ptr null, align 8
18 define void @unroll_default() {
19 entry:
20   br label %do.body
22 do.body:                                          ; preds = %entry
23   %i.0 = phi i32 [ 0, %entry ], [ %inc, %do.body ]
24   %v1 = load i64, ptr @in, align 8
25   store i64 %v1, ptr @out, align 8
26   %inc = add nsw i32 %i.0, 1
27   %cmp = icmp slt i32 %inc, 100
28   br i1 %cmp, label %do.body, label %do.end
30 do.end:                                           ; preds = %do.body
31   ret void
34 ; Check that the same loop in unroll_full is fully unrolled when the default
35 ; unroll threshold is increased by use of the amdgpu.loop.unroll.threshold metadata
36 ; CHECK-LABEL: @unroll_full
37 ; CHECK: entry:
38 ; CHECK-NOT: br i1 %cmp
39 ; CHECK: ret void
41 define void @unroll_full() {
42 entry:
43   br label %do.body
45 do.body:                                          ; preds = %entry
46   %i.0 = phi i32 [ 0, %entry ], [ %inc, %do.body ]
47   %v1 = load i64, ptr @in, align 8
48   store i64 %v1, ptr @out, align 8
49   %inc = add nsw i32 %i.0, 1
50   %cmp = icmp slt i32 %inc, 100
51   br i1 %cmp, label %do.body, label %do.end, !llvm.loop !1
53 do.end:                                           ; preds = %do.body
54   ret void
57 ; Check that the same loop in override_no_unroll is not unrolled when a high default
58 ; unroll threshold specified using the amdgpu-unroll-threshold function attribute
59 ; is overridden by a low threshold using the amdgpu.loop.unroll.threshold metadata
61 ; CHECK-LABEL: @override_no_unroll
62 ; CHECK: entry:
63 ; CHECK: br i1 %cmp
64 ; CHECK: ret void
66 define void @override_no_unroll() #0 {
67 entry:
68   br label %do.body
70 do.body:                                          ; preds = %entry
71   %i.0 = phi i32 [ 0, %entry ], [ %inc, %do.body ]
72   %v1 = load i64, ptr @in, align 8
73   store i64 %v1, ptr @out, align 8
74   %inc = add nsw i32 %i.0, 1
75   %cmp = icmp slt i32 %inc, 100
76   br i1 %cmp, label %do.body, label %do.end, !llvm.loop !3
78 do.end:                                           ; preds = %do.body
79   ret void
82 ; Check that the same loop in override_unroll is fully unrolled when a low default
83 ; unroll threshold specified using the amdgpu-unroll-threshold function attribute
84 ; is overridden by a high threshold using the amdgpu.loop.unroll.threshold metadata
86 ; CHECK-LABEL: @override_unroll
87 ; CHECK: entry:
88 ; CHECK-NOT: br i1 %cmp
89 ; CHECK: ret void
91 define void @override_unroll() #1 {
92 entry:
93   br label %do.body
95 do.body:                                          ; preds = %entry
96   %i.0 = phi i32 [ 0, %entry ], [ %inc, %do.body ]
97   %v1 = load i64, ptr @in, align 8
98   store i64 %v1, ptr @out, align 8
99   %inc = add nsw i32 %i.0, 1
100   %cmp = icmp slt i32 %inc, 100
101   br i1 %cmp, label %do.body, label %do.end, !llvm.loop !1
103 do.end:                                           ; preds = %do.body
104   ret void
107 attributes #0 = { "amdgpu-unroll-threshold"="1000" }
108 attributes #1 = { "amdgpu-unroll-threshold"="100" }
110 !1 = !{!1, !2}
111 !2 = !{!"amdgpu.loop.unroll.threshold", i32 1000}
112 !3 = !{!3, !4}
113 !4 = !{!"amdgpu.loop.unroll.threshold", i32 100}