1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00
llvm-mirror/test/CodeGen/Hexagon/swp-order.ll
James Molloy 25cc728d30 [ModuloSchedule] Peel out prologs and epilogs, generate actual code
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
2019-10-02 12:46:44 +00:00

68 lines
2.2 KiB
LLVM

; RUN: llc -march=hexagon < %s -pipeliner-experimental-cg=true | FileCheck %s
; Test that when we order instructions in a packet we check for
; order dependences so that the source of an order dependence
; appears before the destination.
; CHECK: loop0(.LBB0_[[LOOP:.]],
; CHECK: .LBB0_[[LOOP]]:
; CHECK: = memw
; CHECK: = memw
; CHECK: memw({{.*}}) =
; CHECK: = memw
; CHECK: = memw
; CHECK: endloop0
@g0 = external hidden unnamed_addr constant [19 x i8], align 1
; Function Attrs: nounwind optsize
declare i32 @f0(i8* nocapture readonly, ...) #0
; Function Attrs: nounwind optsize
declare void @f1(i32*, i32*, i32* nocapture readnone) #0
; Function Attrs: argmemonly nounwind
declare i8* @llvm.hexagon.circ.stw(i8*, i32, i32, i32) #1
; Function Attrs: nounwind optsize
define void @f2(i32* %a0, i32* %a1, i32* %a2) #0 {
b0:
%v0 = alloca i32, align 4
call void @f1(i32* %a2, i32* %a0, i32* %v0) #2
%v1 = bitcast i32* %a1 to i8*
br label %b1
b1: ; preds = %b1, %b0
%v2 = phi i32 [ 0, %b0 ], [ %v13, %b1 ]
%v3 = phi i32* [ %a2, %b0 ], [ %v16, %b1 ]
%v4 = phi i32 [ 0, %b0 ], [ %v14, %b1 ]
%v5 = load i32, i32* %a1, align 4, !tbaa !0
%v6 = add nsw i32 %v2, %v5
%v7 = load i32, i32* %v3, align 4, !tbaa !0
%v8 = tail call i8* @llvm.hexagon.circ.stw(i8* %v1, i32 %v7, i32 150995968, i32 4) #3
%v9 = bitcast i8* %v8 to i32*
%v10 = load i32, i32* %v3, align 4, !tbaa !0
%v11 = add nsw i32 %v6, %v10
%v12 = load i32, i32* %v9, align 4, !tbaa !0
%v13 = add nsw i32 %v11, %v12
%v14 = add nsw i32 %v4, 1
%v15 = icmp eq i32 %v14, 2
%v16 = getelementptr i32, i32* %v3, i32 1
br i1 %v15, label %b2, label %b1
b2: ; preds = %b1
%v17 = tail call i32 (i8*, ...) @f0(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @g0, i32 0, i32 0), i32 %v13) #4
ret void
}
attributes #0 = { nounwind optsize "target-cpu"="hexagonv55" }
attributes #1 = { argmemonly nounwind }
attributes #2 = { optsize }
attributes #3 = { nounwind }
attributes #4 = { nounwind optsize }
!0 = !{!1, !1, i64 0}
!1 = !{!"int", !2, i64 0}
!2 = !{!"omnipotent char", !3, i64 0}
!3 = !{!"Simple C/C++ TBAA"}