mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +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
108 lines
4.2 KiB
LLVM
108 lines
4.2 KiB
LLVM
; RUN: llc -march=hexagon < %s -pipeliner-experimental-cg=true | FileCheck %s
|
|
|
|
; Test that the pipeliner correctly fixes up the pipelined CFG when the loop
|
|
; has a constant trip count, and the trip count is less than the number of
|
|
; prolog blocks. Prior to the bug, the pipeliner deleted one extra prolog and
|
|
; epilog stage. We check this by counting the number of sxth instructions.
|
|
|
|
; CHECK: r{{[0-9]+}} = sxth(r{{[0-9]+}})
|
|
; CHECK: r{{[0-9]+}} = sxth(r{{[0-9]+}})
|
|
; CHECK: r{{[0-9]+}} = sxth(r{{[0-9]+}})
|
|
; CHECK: r{{[0-9]+}} = sxth(r{{[0-9]+}})
|
|
|
|
; Function Attrs: nounwind readonly
|
|
define signext i16 @f0(i16* nocapture readonly %a0, i16* nocapture readnone %a1, i16* nocapture readonly %a2, i16* nocapture readonly %a3, i16 signext %a4, i16 signext %a5, i16 signext %a6) #0 {
|
|
b0:
|
|
%v0 = icmp sgt i16 %a5, 0
|
|
br i1 %v0, label %b1, label %b7
|
|
|
|
b1: ; preds = %b0
|
|
%v1 = load i16, i16* %a0, align 2
|
|
%v2 = sext i16 %v1 to i32
|
|
%v3 = load i16, i16* %a3, align 2
|
|
%v4 = sext i16 %v3 to i32
|
|
br label %b2
|
|
|
|
b2: ; preds = %b6, %b1
|
|
%v5 = phi i32 [ 2147483647, %b1 ], [ %v44, %b6 ]
|
|
%v6 = phi i16 [ 0, %b1 ], [ %v45, %b6 ]
|
|
%v7 = phi i16 [ 0, %b1 ], [ %v43, %b6 ]
|
|
%v8 = phi i16* [ %a2, %b1 ], [ %v38, %b6 ]
|
|
%v9 = load i16, i16* %v8, align 2
|
|
%v10 = sext i16 %v9 to i32
|
|
%v11 = tail call i32 @llvm.hexagon.A2.subh.l16.sat.ll(i32 %v2, i32 %v10)
|
|
%v12 = shl i32 %v11, 16
|
|
%v13 = ashr exact i32 %v12, 16
|
|
%v14 = tail call i32 @llvm.hexagon.M2.mpy.sat.ll.s1(i32 %v13, i32 %v4)
|
|
%v15 = tail call i32 @llvm.hexagon.M2.hmmpyl.s1(i32 %v14, i32 %v13)
|
|
%v16 = tail call i32 @llvm.hexagon.S2.asr.r.r.sat(i32 %v15, i32 10)
|
|
%v17 = getelementptr inbounds i16, i16* %v8, i32 1
|
|
br label %b3
|
|
|
|
b3: ; preds = %b3, %b2
|
|
%v18 = phi i16* [ %v8, %b2 ], [ %v19, %b3 ]
|
|
%v19 = phi i16* [ %v17, %b2 ], [ %v38, %b3 ]
|
|
%v20 = phi i32 [ %v16, %b2 ], [ %v36, %b3 ]
|
|
%v21 = phi i32 [ 1, %b2 ], [ %v37, %b3 ]
|
|
%v22 = getelementptr inbounds i16, i16* %a0, i32 %v21
|
|
%v23 = load i16, i16* %v22, align 2
|
|
%v24 = sext i16 %v23 to i32
|
|
%v25 = load i16, i16* %v19, align 2
|
|
%v26 = sext i16 %v25 to i32
|
|
%v27 = tail call i32 @llvm.hexagon.A2.subh.l16.sat.ll(i32 %v24, i32 %v26)
|
|
%v28 = shl i32 %v27, 16
|
|
%v29 = ashr exact i32 %v28, 16
|
|
%v30 = getelementptr inbounds i16, i16* %a3, i32 %v21
|
|
%v31 = load i16, i16* %v30, align 2
|
|
%v32 = sext i16 %v31 to i32
|
|
%v33 = tail call i32 @llvm.hexagon.M2.mpy.sat.ll.s1(i32 %v29, i32 %v32)
|
|
%v34 = tail call i32 @llvm.hexagon.M2.hmmpyl.s1(i32 %v33, i32 %v29)
|
|
%v35 = tail call i32 @llvm.hexagon.S2.asr.r.r.sat(i32 %v34, i32 10)
|
|
%v36 = tail call i32 @llvm.hexagon.A2.addsat(i32 %v20, i32 %v35)
|
|
%v37 = add i32 %v21, 1
|
|
%v38 = getelementptr inbounds i16, i16* %v18, i32 2
|
|
%v39 = icmp eq i32 %v37, 3
|
|
br i1 %v39, label %b4, label %b3
|
|
|
|
b4: ; preds = %b3
|
|
%v40 = tail call i32 @llvm.hexagon.A2.subsat(i32 %v36, i32 %v5)
|
|
%v41 = icmp slt i32 %v40, 0
|
|
br i1 %v41, label %b5, label %b6
|
|
|
|
b5: ; preds = %b4
|
|
%v42 = tail call i32 @llvm.hexagon.A2.addsat(i32 %v36, i32 0)
|
|
br label %b6
|
|
|
|
b6: ; preds = %b5, %b4
|
|
%v43 = phi i16 [ %v6, %b5 ], [ %v7, %b4 ]
|
|
%v44 = phi i32 [ %v42, %b5 ], [ %v5, %b4 ]
|
|
%v45 = add i16 %v6, 1
|
|
%v46 = icmp eq i16 %v45, %a5
|
|
br i1 %v46, label %b7, label %b2
|
|
|
|
b7: ; preds = %b6, %b0
|
|
%v47 = phi i16 [ 0, %b0 ], [ %v43, %b6 ]
|
|
ret i16 %v47
|
|
}
|
|
|
|
; Function Attrs: nounwind readnone
|
|
declare i32 @llvm.hexagon.A2.subh.l16.sat.ll(i32, i32) #1
|
|
|
|
; Function Attrs: nounwind readnone
|
|
declare i32 @llvm.hexagon.M2.mpy.sat.ll.s1(i32, i32) #1
|
|
|
|
; Function Attrs: nounwind readnone
|
|
declare i32 @llvm.hexagon.M2.hmmpyl.s1(i32, i32) #1
|
|
|
|
; Function Attrs: nounwind readnone
|
|
declare i32 @llvm.hexagon.S2.asr.r.r.sat(i32, i32) #1
|
|
|
|
; Function Attrs: nounwind readnone
|
|
declare i32 @llvm.hexagon.A2.addsat(i32, i32) #1
|
|
|
|
; Function Attrs: nounwind readnone
|
|
declare i32 @llvm.hexagon.A2.subsat(i32, i32) #1
|
|
|
|
attributes #0 = { nounwind readonly "target-cpu"="hexagonv60" }
|
|
attributes #1 = { nounwind readnone }
|