53 lines · plain
1; RUN: opt < %s -S -mtriple=amdgcn-- -passes=loop-unroll | FileCheck %s2 3; Check that the loop in unroll_default is not fully unrolled using the default4; unroll threshold5; CHECK-LABEL: @unroll_default6; CHECK: entry:7; CHECK: br i1 %cmp8; CHECK: ret void9 10; Check that the same loop in unroll_full is fully unrolled when the default11; unroll threshold is increased by use of the amdgpu-unroll-threshold attribute12; CHECK-LABEL: @unroll_full13; CHECK: entry:14; CHECK-NOT: br i1 %cmp15; CHECK: ret void16 17@in = internal unnamed_addr global ptr null, align 818@out = internal unnamed_addr global ptr null, align 819 20define void @unroll_default() {21entry:22 br label %do.body23 24do.body: ; preds = %entry25 %i.0 = phi i32 [ 0, %entry ], [ %inc, %do.body ]26 %v1 = load i64, ptr @in, align 827 store i64 %v1, ptr @out, align 828 %inc = add nsw i32 %i.0, 129 %cmp = icmp slt i32 %inc, 10030 br i1 %cmp, label %do.body, label %do.end31 32do.end: ; preds = %do.body33 ret void34}35 36define void @unroll_full() #0 {37entry:38 br label %do.body39 40do.body: ; preds = %entry41 %i.0 = phi i32 [ 0, %entry ], [ %inc, %do.body ]42 %v1 = load i64, ptr @in, align 843 store i64 %v1, ptr @out, align 844 %inc = add nsw i32 %i.0, 145 %cmp = icmp slt i32 %inc, 10046 br i1 %cmp, label %do.body, label %do.end47 48do.end: ; preds = %do.body49 ret void50}51 52attributes #0 = { "amdgpu-unroll-threshold"="1000" }53