llvm.org GIT mirror llvm / 5368a26
[PPC/LoopUnrollRuntime] Don't avoid high-cost trip count computation on the PPC/A2 On X86 (and similar OOO cores) unrolling is very limited, and even if the runtime unrolling is otherwise profitable, the expense of a division to compute the trip count could greatly outweigh the benefits. On the A2, we unroll a lot, and the benefits of unrolling are more significant (seeing a 5x or 6x speedup is not uncommon), so we're more able to tolerate the expense, on average, of a division to compute the trip count. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237947 91177308-0d34-0410-b5e6-96231b3b80d8 Hal Finkel 4 years ago
2 changed file(s) with 31 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
186186 // The A2 is in-order with a deep pipeline, and concatenation unrolling
187187 // helps expose latency-hiding opportunities to the instruction scheduler.
188188 UP.Partial = UP.Runtime = true;
189
190 // We unroll a lot on the A2 (hundreds of instructions), and the benefits
191 // often outweigh the cost of a division to compute the trip count.
192 UP.AllowExpensiveTripCount = true;
189193 }
190194
191195 BaseT::getUnrollingPreferences(L, UP);
0 ; RUN: opt < %s -S -mtriple=powerpc64-unknown-linux-gnu -mcpu=a2 -loop-unroll | FileCheck %s
1
2 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
3
4 ;; Check that we do emit expensive instructions to compute trip
5 ;; counts when unrolling loops on the a2 (because we unroll a lot).
6
7 define i32 @test(i64 %v12, i8* %array, i64* %loc) {
8 ; CHECK-LABEL: @test(
9 ; CHECK: udiv
10 entry:
11 %step = load i64, i64* %loc, !range !0
12 br label %loop
13
14 loop: ; preds = %entry, %loop
15 %k.015 = phi i64 [ %v15, %loop ], [ %v12, %entry ]
16 %v14 = getelementptr inbounds i8, i8* %array, i64 %k.015
17 store i8 0, i8* %v14
18 %v15 = add nuw nsw i64 %k.015, %step
19 %v16 = icmp slt i64 %v15, 8193
20 br i1 %v16, label %loop, label %loopexit
21
22 loopexit: ; preds = %loop
23 ret i32 0
24 }
25
26 !0 = !{i64 1, i64 100}