brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · 986df8b Raw
91 lines · plain
1; RUN: opt -passes=loop-unroll -S -unroll-runtime %s | FileCheck %s --check-prefix=NOFORCE2; RUN: opt -passes=loop-unroll -S -unroll-runtime -aarch64-force-unroll-threshold=500 %s | FileCheck %s --check-prefix=FORCE3 4; The loop has a small runtime upper bound (at most four iterations) but a5; relatively expensive body. With runtime unrolling enabled, the cost model6; still leaves the loop rolled. Raising the AArch64 force threshold overrides7; that decision and unrolls.8 9target triple = "aarch64-unknown-linux-gnu"10 11define void @force_small_loop(ptr nocapture %a, ptr nocapture %b, i32 %n) {12entry:13  br label %loop14 15; NOFORCE-LABEL: @force_small_loop(16; NOFORCE:       loop:17; NOFORCE:         br i1 %cond, label %body, label %exit18; NOFORCE:       body:19; NOFORCE:         store i32 %mix15, ptr %ptrb, align 420; NOFORCE:       latch:21; NOFORCE:         br i1 %cmp2, label %loop, label %exit22; NOFORCE:       ret void23; NOFORCE-NOT:   loop.1:24;25; FORCE-LABEL: @force_small_loop(26; FORCE:       loop:27; FORCE:         br i1 %cond, label %body, label %exit28; FORCE:       loop.1:29; FORCE:         br i1 true, label %body.1, label %exit30; FORCE:       body.1:31; FORCE:         store i32 %mix15.1, ptr %ptrb.1, align 432; FORCE:       latch.1:33; FORCE:         br i1 %cmp2.1, label %loop, label %exit34; FORCE:       ret void35 36loop:37  %i = phi i32 [ 0, %entry ], [ %inc, %latch ]38  %ptra = getelementptr inbounds i32, ptr %a, i32 %i39  %pa = load i32, ptr %ptra, align 440  %tmp0 = mul nsw i32 %pa, %pa41  %tmp1 = add nsw i32 %tmp0, %pa42  %tmp2 = shl i32 %tmp1, 143  %tmp3 = ashr i32 %tmp2, 144  %tmp4 = xor i32 %tmp3, %pa45  %tmp5 = add nsw i32 %tmp4, 746  %tmp6 = mul nsw i32 %tmp5, 547  %tmp7 = add nsw i32 %tmp6, %tmp448  %tmp8 = mul nsw i32 %tmp7, %tmp349  %tmp9 = add nsw i32 %tmp8, %tmp750  %tmp10 = xor i32 %tmp9, %tmp651  %tmp11 = add nsw i32 %tmp10, %tmp852  %tmp12 = mul nsw i32 %tmp11, 953  %tmp13 = add nsw i32 %tmp12, %tmp1054  %tmp14 = xor i32 %tmp13, %tmp1155  %cond = icmp ult i32 %i, %n56  br i1 %cond, label %body, label %exit57 58body:59  %ptrb = getelementptr inbounds i32, ptr %b, i32 %i60  %pb = load i32, ptr %ptrb, align 461  %sum = add nsw i32 %pb, %tmp1462  %diff = sub nsw i32 %sum, %pa63  %mix1 = mul nsw i32 %diff, 364  %mix2 = add nsw i32 %mix1, %tmp365  %mix3 = xor i32 %mix2, %diff66  %mix4 = add nsw i32 %mix3, %tmp067  %mix5 = mul nsw i32 %mix4, 1168  %mix6 = add nsw i32 %mix5, %mix269  %mix7 = xor i32 %mix6, %mix570  %mix8 = add nsw i32 %mix7, %mix371  %mix9 = mul nsw i32 %mix8, 1372  %mix10 = add nsw i32 %mix9, %mix873  %mix11 = xor i32 %mix10, %mix774  %mix12 = add nsw i32 %mix11, %mix675  %mix13 = mul nsw i32 %mix12, 1776  %mix14 = add nsw i32 %mix13, %mix977  %mix15 = xor i32 %mix14, %mix1078  store i32 %mix15, ptr %ptrb, align 479  br label %latch80 81latch:82  %inc = add nuw nsw i32 %i, 183  %cmp.limit = icmp ult i32 %n, 484  %upper = select i1 %cmp.limit, i32 %n, i32 485  %cmp2 = icmp ult i32 %inc, %upper86  br i1 %cmp2, label %loop, label %exit87 88exit:89  ret void90}91