mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:32:44 +01:00
25cc728d30
Summary: This extends the PeelingModuloScheduleExpander to generate prolog and epilog code, and correctly stitch uses through the prolog, kernel, epilog DAG. The key concept in this patch is to ensure that all transforms are *local*; only a function of a block and its immediate predecessor and successor. By defining the problem in this way we can inductively rewrite the entire DAG using only local knowledge that is easy to reason about. For example, we assume that all prologs and epilogs are near-perfect clones of the steady-state kernel. This means that if a block has an instruction that is predicated out, we can redirect all users of that instruction to that equivalent instruction in our immediate predecessor. As all blocks are clones, every instruction must have an equivalent in every other block. Similarly we can make the assumption by construction that if a value defined in a block is used outside that block, the only possible user is its immediate successors. We maintain this even for values that are used outside the loop by creating a limited form of LCSSA. This code isn't small, but it isn't complex. Enabled a bunch of testing from Hexagon. There are a couple of tests not enabled yet; I'm about 80% sure there isn't buggy codegen but the tests are checking for patterns that we don't produce. Those still need a bit more investigation. In the meantime we (Google) are happy with the code produced by this on our downstream SMS implementation, and believe it generates correct code. Subscribers: mgorny, hiraditya, jsji, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68205 llvm-svn: 373462
68 lines
2.5 KiB
LLVM
68 lines
2.5 KiB
LLVM
; RUN: llc -march=hexagon -enable-pipeliner -stats \
|
|
; RUN: -pipeliner-prune-loop-carried=false -fp-contract=fast \
|
|
; RUN: -o /dev/null < %s 2>&1 -pipeliner-experimental-cg=true | FileCheck %s --check-prefix=STATS
|
|
; REQUIRES: asserts
|
|
|
|
; That that we do not pipeline this loop. The recurrence is too large. If
|
|
; we pipeline this example, that means we're not checking the complete
|
|
; chain of dependences.
|
|
|
|
; STATS-NOT: 1 pipeliner - Number of loops software pipelined
|
|
|
|
; Function Attrs: nounwind
|
|
define void @f0(i32 %a0, i32 %a1, double %a2, double %a3, i8* %a4, i8* %a5, i8* %a6, i8* %a7, i8* %a8, [1000 x i8]* %a9, [1000 x i8]* %a10, [1000 x i8]* %a11) #0 {
|
|
b0:
|
|
br i1 undef, label %b1, label %b4
|
|
|
|
b1: ; preds = %b3, %b0
|
|
br label %b2
|
|
|
|
b2: ; preds = %b2, %b1
|
|
%v0 = phi i8* [ %v22, %b2 ], [ %a5, %b1 ]
|
|
%v1 = phi i8* [ %v23, %b2 ], [ %a6, %b1 ]
|
|
%v2 = phi i8* [ %v24, %b2 ], [ %a7, %b1 ]
|
|
%v3 = phi i32 [ %v20, %b2 ], [ 0, %b1 ]
|
|
%v4 = load i8, i8* %v0, align 1, !tbaa !0
|
|
%v5 = zext i8 %v4 to i32
|
|
%v6 = load i8, i8* %v1, align 1, !tbaa !0
|
|
%v7 = sext i8 %v6 to i32
|
|
%v8 = load i8, i8* %v2, align 1, !tbaa !0
|
|
%v9 = sext i8 %v8 to i32
|
|
%v10 = mul nsw i32 %v9, %v7
|
|
%v11 = add nsw i32 %v10, %v5
|
|
%v12 = trunc i32 %v11 to i8
|
|
store i8 %v12, i8* undef, align 1, !tbaa !0
|
|
%v13 = load i8, i8* %v2, align 1, !tbaa !0
|
|
%v14 = sext i8 %v13 to i32
|
|
%v15 = load i8, i8* undef, align 1, !tbaa !0
|
|
%v16 = sext i8 %v15 to i32
|
|
%v17 = mul nsw i32 %v16, %v14
|
|
%v18 = add i32 %v17, %v11
|
|
%v19 = trunc i32 %v18 to i8
|
|
store i8 %v19, i8* %v0, align 1, !tbaa !0
|
|
%v20 = add nsw i32 %v3, 1
|
|
store i8 0, i8* undef, align 1, !tbaa !0
|
|
%v21 = icmp eq i32 %v20, undef
|
|
%v22 = getelementptr i8, i8* %v0, i32 1
|
|
%v23 = getelementptr i8, i8* %v1, i32 1
|
|
%v24 = getelementptr i8, i8* %v2, i32 1
|
|
br i1 %v21, label %b3, label %b2
|
|
|
|
b3: ; preds = %b2
|
|
tail call void @f1(i32 %a1, i8* %a4, i8* %a5, i8* %a6, i8* %a7, i8* %a8, [1000 x i8]* %a9, [1000 x i8]* %a10, [1000 x i8]* %a11, i8 signext 1) #2
|
|
br i1 undef, label %b4, label %b1
|
|
|
|
b4: ; preds = %b3, %b0
|
|
ret void
|
|
}
|
|
|
|
declare void @f1(i32, i8*, i8*, i8*, i8*, i8*, [1000 x i8]*, [1000 x i8]*, [1000 x i8]*, i8 signext) #1
|
|
|
|
attributes #0 = { nounwind "target-cpu"="hexagonv55" }
|
|
attributes #1 = { "target-cpu"="hexagonv55" }
|
|
attributes #2 = { nounwind }
|
|
|
|
!0 = !{!1, !1, i64 0}
|
|
!1 = !{!"omnipotent char", !2, i64 0}
|
|
!2 = !{!"Simple C/C++ TBAA"}
|