brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.6 KiB · ffc0ae9 Raw
114 lines · plain
1; RUN: opt < %s -S -mtriple=amdgcn-- -passes=loop-unroll | FileCheck %s2 3; Check the handling of amdgpu.loop.unroll.threshold metadata which can be used to4; set the default threshold for a loop. This metadata overrides both the AMDGPU5; default, and any value specified by the amdgpu-unroll-threshold function attribute6; (which sets a threshold for all loops in the function).7 8; Check that the loop in unroll_default is not fully unrolled using the default9; unroll threshold10; CHECK-LABEL: @unroll_default11; CHECK: entry:12; CHECK: br i1 %cmp13; CHECK: ret void14 15@in = internal unnamed_addr global ptr null, align 816@out = internal unnamed_addr global ptr null, align 817 18define void @unroll_default() {19entry:20  br label %do.body21 22do.body:                                          ; preds = %entry23  %i.0 = phi i32 [ 0, %entry ], [ %inc, %do.body ]24  %v1 = load i64, ptr @in, align 825  store i64 %v1, ptr @out, align 826  %inc = add nsw i32 %i.0, 127  %cmp = icmp slt i32 %inc, 10028  br i1 %cmp, label %do.body, label %do.end29 30do.end:                                           ; preds = %do.body31  ret void32}33 34; Check that the same loop in unroll_full is fully unrolled when the default35; unroll threshold is increased by use of the amdgpu.loop.unroll.threshold metadata36; CHECK-LABEL: @unroll_full37; CHECK: entry:38; CHECK-NOT: br i1 %cmp39; CHECK: ret void40 41define void @unroll_full() {42entry:43  br label %do.body44 45do.body:                                          ; preds = %entry46  %i.0 = phi i32 [ 0, %entry ], [ %inc, %do.body ]47  %v1 = load i64, ptr @in, align 848  store i64 %v1, ptr @out, align 849  %inc = add nsw i32 %i.0, 150  %cmp = icmp slt i32 %inc, 10051  br i1 %cmp, label %do.body, label %do.end, !llvm.loop !152 53do.end:                                           ; preds = %do.body54  ret void55}56 57; Check that the same loop in override_no_unroll is not unrolled when a high default58; unroll threshold specified using the amdgpu-unroll-threshold function attribute59; is overridden by a low threshold using the amdgpu.loop.unroll.threshold metadata60 61; CHECK-LABEL: @override_no_unroll62; CHECK: entry:63; CHECK: br i1 %cmp64; CHECK: ret void65 66define void @override_no_unroll() #0 {67entry:68  br label %do.body69 70do.body:                                          ; preds = %entry71  %i.0 = phi i32 [ 0, %entry ], [ %inc, %do.body ]72  %v1 = load i64, ptr @in, align 873  store i64 %v1, ptr @out, align 874  %inc = add nsw i32 %i.0, 175  %cmp = icmp slt i32 %inc, 10076  br i1 %cmp, label %do.body, label %do.end, !llvm.loop !377 78do.end:                                           ; preds = %do.body79  ret void80}81 82; Check that the same loop in override_unroll is fully unrolled when a low default83; unroll threshold specified using the amdgpu-unroll-threshold function attribute84; is overridden by a high threshold using the amdgpu.loop.unroll.threshold metadata85 86; CHECK-LABEL: @override_unroll87; CHECK: entry:88; CHECK-NOT: br i1 %cmp89; CHECK: ret void90 91define void @override_unroll() #1 {92entry:93  br label %do.body94 95do.body:                                          ; preds = %entry96  %i.0 = phi i32 [ 0, %entry ], [ %inc, %do.body ]97  %v1 = load i64, ptr @in, align 898  store i64 %v1, ptr @out, align 899  %inc = add nsw i32 %i.0, 1100  %cmp = icmp slt i32 %inc, 100101  br i1 %cmp, label %do.body, label %do.end, !llvm.loop !1102 103do.end:                                           ; preds = %do.body104  ret void105}106 107attributes #0 = { "amdgpu-unroll-threshold"="1000" }108attributes #1 = { "amdgpu-unroll-threshold"="100" }109 110!1 = !{!1, !2}111!2 = !{!"amdgpu.loop.unroll.threshold", i32 1000}112!3 = !{!3, !4}113!4 = !{!"amdgpu.loop.unroll.threshold", i32 100}114