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