brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 241ed28 Raw
40 lines · plain
1; RUN: opt < %s -S -passes=loop-unroll -unroll-max-iteration-count-to-analyze=1000 -unroll-threshold=10 -unroll-max-percent-threshold-boost=100 | FileCheck %s -check-prefix=TEST12; RUN: opt < %s -S -passes=loop-unroll -unroll-max-iteration-count-to-analyze=1000 -unroll-threshold=20 -unroll-max-percent-threshold-boost=200 | FileCheck %s -check-prefix=TEST23; RUN: opt < %s -S -passes=loop-unroll -unroll-max-iteration-count-to-analyze=1000 -unroll-threshold=20 -unroll-max-percent-threshold-boost=100 | FileCheck %s -check-prefix=TEST34 5; This test is a copy of full-unroll-heuristics.ll but with the constant6; wrapped in an extra struct. This should not hinder the analysis.7 8; If the absolute threshold is too low, we should not unroll:9; TEST1: %array_const_idx = getelementptr inbounds { [9 x i32] }, ptr @known_constant, i64 0, i32 0, i64 %iv10 11; Otherwise, we should:12; TEST2-NOT: %array_const_idx = getelementptr inbounds { [9 x i32] }, ptr @known_constant, i64 0, i32 0, i64 %iv13 14; If we do not boost threshold, the unroll will not happen:15; TEST3: %array_const_idx = getelementptr inbounds { [9 x i32] }, ptr @known_constant, i64 0, i32 0, i64 %iv16 17@known_constant = internal unnamed_addr constant { [9 x i32] } { [9 x i32] [i32 0, i32 -1, i32 0, i32 -1, i32 5, i32 -1, i32 0, i32 -1, i32 0] }, align 1618 19define i32 @foo(ptr noalias nocapture readonly %src) {20entry:21  br label %loop22 23loop:                                                ; preds = %loop, %entry24  %iv = phi i64 [ 0, %entry ], [ %inc, %loop ]25  %r  = phi i32 [ 0, %entry ], [ %add, %loop ]26  %arrayidx = getelementptr inbounds i32, ptr %src, i64 %iv27  %src_element = load i32, ptr %arrayidx, align 428  %array_const_idx = getelementptr inbounds { [9 x i32] }, ptr @known_constant, i64 0, i32 0, i64 %iv29  %const_array_element = load i32, ptr %array_const_idx, align 430  %mul = mul nsw i32 %src_element, %const_array_element31  %add = add nsw i32 %mul, %r32  %inc = add nuw nsw i64 %iv, 133  %exitcond86.i = icmp eq i64 %inc, 934  br i1 %exitcond86.i, label %loop.end, label %loop35 36loop.end:                                            ; preds = %loop37  %r.lcssa = phi i32 [ %r, %loop ]38  ret i32 %r.lcssa39}40