| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6 | |
| ; RUN: opt -S -mtriple=amdgpu9.0a-amd-amdhsa -passes=loop-unroll < %s | FileCheck %s | |
| ; Loop unrolling uses TCK_SizeAndLatency for non-minsize functions. Even though | |
| ; AMDGPU reports low size-latency costs for cmp/selects to enable SimplifyCFG | |
| ; speculation, this wide loop should still remain too expensive to unroll. | |
| define void @wide_select_loop(ptr addrspace(1) %p, <16 x float> %a, <16 x float> %b) { | |
| ; CHECK-LABEL: define void @wide_select_loop( | |
| ; CHECK-SAME: ptr addrspace(1) [[P:%.*]], <16 x float> [[A:%.*]], <16 x float> [[B:%.*]]) { | |
| ; CHECK-NEXT: [[ENTRY:.*]]: | |
| ; CHECK-NEXT: br label %[[LOOP:.*]] | |
| ; CHECK: [[LOOP]]: | |
| ; CHECK-NEXT: [[I:%.*]] = phi i32 [ 0, %[[ENTRY]] ], [ [[INC:%.*]], %[[LOOP]] ] | |
| ; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds <16 x float>, ptr addrspace(1) [[P]], i32 [[I]] | |
| ; CHECK-NEXT: [[V:%.*]] = load <16 x float>, ptr addrspace(1) [[GEP]], align 64 | |
| ; CHECK-NEXT: [[C1:%.*]] = fcmp ogt <16 x float> [[V]], [[A]] | |
| ; CHECK-NEXT: [[S1:%.*]] = select <16 x i1> [[C1]], <16 x float> [[V]], <16 x float> [[B]] | |
| ; CHECK-NEXT: [[C2:%.*]] = fcmp ogt <16 x float> [[S1]], [[A]] | |
| ; CHECK-NEXT: [[S2:%.*]] = select <16 x i1> [[C2]], <16 x float> [[S1]], <16 x float> [[B]] | |
| ; CHECK-NEXT: [[C3:%.*]] = fcmp ogt <16 x float> [[S2]], [[A]] | |
| ; CHECK-NEXT: [[S3:%.*]] = select <16 x i1> [[C3]], <16 x float> [[S2]], <16 x float> [[B]] | |
| ; CHECK-NEXT: [[C4:%.*]] = fcmp ogt <16 x float> [[S3]], [[A]] | |
| ; CHECK-NEXT: [[S4:%.*]] = select <16 x i1> [[C4]], <16 x float> [[S3]], <16 x float> [[B]] | |
| ; CHECK-NEXT: [[C5:%.*]] = fcmp ogt <16 x float> [[S4]], [[A]] | |
| ; CHECK-NEXT: [[S5:%.*]] = select <16 x i1> [[C5]], <16 x float> [[S4]], <16 x float> [[B]] | |
| ; CHECK-NEXT: store <16 x float> [[S5]], ptr addrspace(1) [[GEP]], align 64 | |
| ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I]], 1 | |
| ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], 64 | |
| ; CHECK-NEXT: br i1 [[CMP]], label %[[LOOP]], label %[[EXIT:.*]] | |
| ; CHECK: [[EXIT]]: | |
| ; CHECK-NEXT: ret void | |
| ; | |
| entry: | |
| br label %loop | |
| loop: | |
| %i = phi i32 [ 0, %entry ], [ %inc, %loop ] | |
| %gep = getelementptr inbounds <16 x float>, ptr addrspace(1) %p, i32 %i | |
| %v = load <16 x float>, ptr addrspace(1) %gep, align 64 | |
| %c1 = fcmp ogt <16 x float> %v, %a | |
| %s1 = select <16 x i1> %c1, <16 x float> %v, <16 x float> %b | |
| %c2 = fcmp ogt <16 x float> %s1, %a | |
| %s2 = select <16 x i1> %c2, <16 x float> %s1, <16 x float> %b | |
| %c3 = fcmp ogt <16 x float> %s2, %a | |
| %s3 = select <16 x i1> %c3, <16 x float> %s2, <16 x float> %b | |
| %c4 = fcmp ogt <16 x float> %s3, %a | |
| %s4 = select <16 x i1> %c4, <16 x float> %s3, <16 x float> %b | |
| %c5 = fcmp ogt <16 x float> %s4, %a | |
| %s5 = select <16 x i1> %c5, <16 x float> %s4, <16 x float> %b | |
| store <16 x float> %s5, ptr addrspace(1) %gep, align 64 | |
| %inc = add nuw nsw i32 %i, 1 | |
| %cmp = icmp slt i32 %inc, 64 | |
| br i1 %cmp, label %loop, label %exit | |
| exit: | |
| ret void | |
| } |