llvm-project/llvm/test/CodeGen/Hexagon/swp-bad-sched.ll

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

148 lines
5.4 KiB
LLVM
Raw Normal View History

; REQUIRES: asserts
[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 20:46:44 +08:00
; RUN: llc -march=hexagon -enable-pipeliner -enable-aa-sched-mi < %s -pipeliner-experimental-cg=true | FileCheck %s
; CHECK: loop0(
; CHECK: loop0(.LBB0_[[LOOP:.]],
; CHECK: .LBB0_[[LOOP]]:
; CHECK: or
; CHECK: or
; CHECK: }
; CHECK: {
; CHECK: }
; CHECK: {
; CHECK: memw
; CHECK-NEXT: }{{[ \t]*}}:endloop0
; Function Attrs: nounwind
define void @f0([576 x i32]* nocapture %a0, i32 %a1, i32* nocapture %a2) #0 {
b0:
%v0 = icmp sgt i32 %a1, 0
br i1 %v0, label %b1, label %b9
b1: ; preds = %b0
%v1 = icmp ugt i32 %a1, 3
%v2 = add i32 %a1, -3
br i1 %v1, label %b2, label %b5
b2: ; preds = %b1
br label %b3
b3: ; preds = %b3, %b2
%v3 = phi i32 [ %v48, %b3 ], [ 0, %b2 ]
%v4 = phi i32 [ %v46, %b3 ], [ 0, %b2 ]
%v5 = phi i32 [ %v49, %b3 ], [ 0, %b2 ]
%v6 = getelementptr inbounds [576 x i32], [576 x i32]* %a0, i32 0, i32 %v5
%v7 = load i32, i32* %v6, align 4, !tbaa !0
%v8 = getelementptr inbounds [576 x i32], [576 x i32]* %a0, i32 1, i32 %v5
%v9 = load i32, i32* %v8, align 4, !tbaa !0
%v10 = add nsw i32 %v9, %v7
store i32 %v10, i32* %v6, align 4, !tbaa !0
%v11 = sub nsw i32 %v7, %v9
store i32 %v11, i32* %v8, align 4, !tbaa !0
%v12 = tail call i32 @llvm.hexagon.A2.abs(i32 %v10)
%v13 = or i32 %v12, %v4
%v14 = tail call i32 @llvm.hexagon.A2.abs(i32 %v11)
%v15 = or i32 %v14, %v3
%v16 = add nsw i32 %v5, 1
%v17 = getelementptr inbounds [576 x i32], [576 x i32]* %a0, i32 0, i32 %v16
%v18 = load i32, i32* %v17, align 4, !tbaa !0
%v19 = getelementptr inbounds [576 x i32], [576 x i32]* %a0, i32 1, i32 %v16
%v20 = load i32, i32* %v19, align 4, !tbaa !0
%v21 = add nsw i32 %v20, %v18
store i32 %v21, i32* %v17, align 4, !tbaa !0
%v22 = sub nsw i32 %v18, %v20
store i32 %v22, i32* %v19, align 4, !tbaa !0
%v23 = tail call i32 @llvm.hexagon.A2.abs(i32 %v21)
%v24 = or i32 %v23, %v13
%v25 = tail call i32 @llvm.hexagon.A2.abs(i32 %v22)
%v26 = or i32 %v25, %v15
%v27 = add nsw i32 %v5, 2
%v28 = getelementptr inbounds [576 x i32], [576 x i32]* %a0, i32 0, i32 %v27
%v29 = load i32, i32* %v28, align 4, !tbaa !0
%v30 = getelementptr inbounds [576 x i32], [576 x i32]* %a0, i32 1, i32 %v27
%v31 = load i32, i32* %v30, align 4, !tbaa !0
%v32 = add nsw i32 %v31, %v29
store i32 %v32, i32* %v28, align 4, !tbaa !0
%v33 = sub nsw i32 %v29, %v31
store i32 %v33, i32* %v30, align 4, !tbaa !0
%v34 = tail call i32 @llvm.hexagon.A2.abs(i32 %v32)
%v35 = or i32 %v34, %v24
%v36 = tail call i32 @llvm.hexagon.A2.abs(i32 %v33)
%v37 = or i32 %v36, %v26
%v38 = add nsw i32 %v5, 3
%v39 = getelementptr inbounds [576 x i32], [576 x i32]* %a0, i32 0, i32 %v38
%v40 = load i32, i32* %v39, align 4, !tbaa !0
%v41 = getelementptr inbounds [576 x i32], [576 x i32]* %a0, i32 1, i32 %v38
%v42 = load i32, i32* %v41, align 4, !tbaa !0
%v43 = add nsw i32 %v42, %v40
store i32 %v43, i32* %v39, align 4, !tbaa !0
%v44 = sub nsw i32 %v40, %v42
store i32 %v44, i32* %v41, align 4, !tbaa !0
%v45 = tail call i32 @llvm.hexagon.A2.abs(i32 %v43)
%v46 = or i32 %v45, %v35
%v47 = tail call i32 @llvm.hexagon.A2.abs(i32 %v44)
%v48 = or i32 %v47, %v37
%v49 = add nsw i32 %v5, 4
%v50 = icmp slt i32 %v49, %v2
br i1 %v50, label %b3, label %b4
b4: ; preds = %b3
br label %b5
b5: ; preds = %b4, %b1
%v51 = phi i32 [ 0, %b1 ], [ %v49, %b4 ]
%v52 = phi i32 [ 0, %b1 ], [ %v48, %b4 ]
%v53 = phi i32 [ 0, %b1 ], [ %v46, %b4 ]
%v54 = icmp eq i32 %v51, %a1
br i1 %v54, label %b9, label %b6
b6: ; preds = %b5
br label %b7
b7: ; preds = %b7, %b6
%v55 = phi i32 [ %v67, %b7 ], [ %v52, %b6 ]
%v56 = phi i32 [ %v65, %b7 ], [ %v53, %b6 ]
%v57 = phi i32 [ %v68, %b7 ], [ %v51, %b6 ]
%v58 = getelementptr inbounds [576 x i32], [576 x i32]* %a0, i32 0, i32 %v57
%v59 = load i32, i32* %v58, align 4, !tbaa !0
%v60 = getelementptr inbounds [576 x i32], [576 x i32]* %a0, i32 1, i32 %v57
%v61 = load i32, i32* %v60, align 4, !tbaa !0
%v62 = add nsw i32 %v61, %v59
store i32 %v62, i32* %v58, align 4, !tbaa !0
%v63 = sub nsw i32 %v59, %v61
store i32 %v63, i32* %v60, align 4, !tbaa !0
%v64 = tail call i32 @llvm.hexagon.A2.abs(i32 %v62)
%v65 = or i32 %v64, %v56
%v66 = tail call i32 @llvm.hexagon.A2.abs(i32 %v63)
%v67 = or i32 %v66, %v55
%v68 = add nsw i32 %v57, 1
%v69 = icmp eq i32 %v68, %a1
br i1 %v69, label %b8, label %b7
b8: ; preds = %b7
br label %b9
b9: ; preds = %b8, %b5, %b0
%v70 = phi i32 [ 0, %b0 ], [ %v52, %b5 ], [ %v67, %b8 ]
%v71 = phi i32 [ 0, %b0 ], [ %v53, %b5 ], [ %v65, %b8 ]
%v72 = load i32, i32* %a2, align 4, !tbaa !0
%v73 = or i32 %v72, %v71
store i32 %v73, i32* %a2, align 4, !tbaa !0
%v74 = getelementptr inbounds i32, i32* %a2, i32 1
%v75 = load i32, i32* %v74, align 4, !tbaa !0
%v76 = or i32 %v75, %v70
store i32 %v76, i32* %v74, align 4, !tbaa !0
ret void
}
; Function Attrs: nounwind readnone
declare i32 @llvm.hexagon.A2.abs(i32) #1
attributes #0 = { nounwind }
attributes #1 = { nounwind readnone }
!0 = !{!1, !1, i64 0}
!1 = !{!"int", !2}
!2 = !{!"omnipotent char", !3}
!3 = !{!"Simple C/C++ TBAA"}