2019-03-14 03:04:45 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
|
|
; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
|
Codegen: Tail-duplicate during placement.
The tail duplication pass uses an assumed layout when making duplication
decisions. This is fine, but passes up duplication opportunities that
may arise when blocks are outlined. Because we want the updated CFG to
affect subsequent placement decisions, this change must occur during
placement.
In order to achieve this goal, TailDuplicationPass is split into a
utility class, TailDuplicator, and the pass itself. The pass delegates
nearly everything to the TailDuplicator object, except for looping over
the blocks in a function. This allows the same code to be used for tail
duplication in both places.
This change, in concert with outlining optional branches, allows
triangle shaped code to perform much better, esepecially when the
taken/untaken branches are correlated, as it creates a second spine when
the tests are small enough.
Issue from previous rollback fixed, and a new test was added for that
case as well. Issue was worklist/scheduling/taildup issue in layout.
Issue from 2nd rollback fixed, with 2 additional tests. Issue was
tail merging/loop info/tail-duplication causing issue with loops that share
a header block.
Issue with early tail-duplication of blocks that branch to a fallthrough
predecessor fixed with test case: tail-dup-branch-to-fallthrough.ll
Differential revision: https://reviews.llvm.org/D18226
llvm-svn: 283934
2016-10-12 04:36:43 +08:00
|
|
|
|
|
|
|
; Function Attrs: uwtable
|
|
|
|
; When tail-duplicating during placement, we work backward from blocks with
|
|
|
|
; multiple successors. In this case, the block dup1 gets duplicated into dup2
|
|
|
|
; and if.then64, and then the block dup2 gets duplicated into land.lhs.true
|
|
|
|
; and if.end70
|
2019-03-14 03:04:45 +08:00
|
|
|
|
2019-03-25 01:02:08 +08:00
|
|
|
define void @repeated_tail_dup(i1 %a1, i1 %a2, i32* %a4, i32* %a5, i8* %a6, i32 %a7) #0 align 2 {
|
2019-03-14 03:04:45 +08:00
|
|
|
; CHECK-LABEL: repeated_tail_dup:
|
|
|
|
; CHECK: # %bb.0: # %entry
|
|
|
|
; CHECK-NEXT: .p2align 4, 0x90
|
|
|
|
; CHECK-NEXT: .LBB0_1: # %for.cond
|
|
|
|
; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
|
|
|
|
; CHECK-NEXT: testb $1, %dil
|
|
|
|
; CHECK-NEXT: je .LBB0_3
|
|
|
|
; CHECK-NEXT: # %bb.2: # %land.lhs.true
|
|
|
|
; CHECK-NEXT: # in Loop: Header=BB0_1 Depth=1
|
|
|
|
; CHECK-NEXT: movl $10, (%rdx)
|
|
|
|
; CHECK-NEXT: jmp .LBB0_6
|
|
|
|
; CHECK-NEXT: .p2align 4, 0x90
|
|
|
|
; CHECK-NEXT: .LBB0_3: # %if.end56
|
|
|
|
; CHECK-NEXT: # in Loop: Header=BB0_1 Depth=1
|
|
|
|
; CHECK-NEXT: testb $1, %sil
|
|
|
|
; CHECK-NEXT: je .LBB0_5
|
|
|
|
; CHECK-NEXT: # %bb.4: # %if.then64
|
|
|
|
; CHECK-NEXT: # in Loop: Header=BB0_1 Depth=1
|
|
|
|
; CHECK-NEXT: movb $1, (%r8)
|
2019-03-25 01:02:08 +08:00
|
|
|
; CHECK-NEXT: testl %r9d, %r9d
|
2019-03-14 03:04:45 +08:00
|
|
|
; CHECK-NEXT: je .LBB0_1
|
|
|
|
; CHECK-NEXT: jmp .LBB0_8
|
|
|
|
; CHECK-NEXT: .p2align 4, 0x90
|
|
|
|
; CHECK-NEXT: .LBB0_5: # %if.end70
|
|
|
|
; CHECK-NEXT: # in Loop: Header=BB0_1 Depth=1
|
|
|
|
; CHECK-NEXT: movl $12, (%rdx)
|
|
|
|
; CHECK-NEXT: .LBB0_6: # %dup2
|
|
|
|
; CHECK-NEXT: # in Loop: Header=BB0_1 Depth=1
|
|
|
|
; CHECK-NEXT: movl $2, (%rcx)
|
2019-03-25 01:02:08 +08:00
|
|
|
; CHECK-NEXT: testl %r9d, %r9d
|
2019-03-14 03:04:45 +08:00
|
|
|
; CHECK-NEXT: je .LBB0_1
|
|
|
|
; CHECK-NEXT: .LBB0_8: # %for.end
|
|
|
|
; CHECK-NEXT: retq
|
Codegen: Tail-duplicate during placement.
The tail duplication pass uses an assumed layout when making duplication
decisions. This is fine, but passes up duplication opportunities that
may arise when blocks are outlined. Because we want the updated CFG to
affect subsequent placement decisions, this change must occur during
placement.
In order to achieve this goal, TailDuplicationPass is split into a
utility class, TailDuplicator, and the pass itself. The pass delegates
nearly everything to the TailDuplicator object, except for looping over
the blocks in a function. This allows the same code to be used for tail
duplication in both places.
This change, in concert with outlining optional branches, allows
triangle shaped code to perform much better, esepecially when the
taken/untaken branches are correlated, as it creates a second spine when
the tests are small enough.
Issue from previous rollback fixed, and a new test was added for that
case as well. Issue was worklist/scheduling/taildup issue in layout.
Issue from 2nd rollback fixed, with 2 additional tests. Issue was
tail merging/loop info/tail-duplication causing issue with loops that share
a header block.
Issue with early tail-duplication of blocks that branch to a fallthrough
predecessor fixed with test case: tail-dup-branch-to-fallthrough.ll
Differential revision: https://reviews.llvm.org/D18226
llvm-svn: 283934
2016-10-12 04:36:43 +08:00
|
|
|
entry:
|
|
|
|
br label %for.cond
|
|
|
|
|
|
|
|
for.cond: ; preds = %dup1, %entry
|
|
|
|
br i1 %a1, label %land.lhs.true, label %if.end56
|
|
|
|
|
|
|
|
land.lhs.true: ; preds = %for.cond
|
|
|
|
store i32 10, i32* %a4, align 8
|
|
|
|
br label %dup2
|
|
|
|
|
|
|
|
if.end56: ; preds = %for.cond
|
|
|
|
br i1 %a2, label %if.then64, label %if.end70
|
|
|
|
|
|
|
|
if.then64: ; preds = %if.end56
|
|
|
|
store i8 1, i8* %a6, align 1
|
|
|
|
br label %dup1
|
|
|
|
|
|
|
|
if.end70: ; preds = %if.end56
|
|
|
|
store i32 12, i32* %a4, align 8
|
|
|
|
br label %dup2
|
|
|
|
|
|
|
|
dup2: ; preds = %if.end70, %land.lhs.true
|
|
|
|
store i32 2, i32* %a5, align 4
|
|
|
|
br label %dup1
|
|
|
|
|
|
|
|
dup1: ; preds = %dup2, %if.then64
|
|
|
|
%val = load i32, i32* %a4, align 8
|
2019-03-25 01:02:08 +08:00
|
|
|
%switch = icmp ult i32 %a7, 1
|
Codegen: Tail-duplicate during placement.
The tail duplication pass uses an assumed layout when making duplication
decisions. This is fine, but passes up duplication opportunities that
may arise when blocks are outlined. Because we want the updated CFG to
affect subsequent placement decisions, this change must occur during
placement.
In order to achieve this goal, TailDuplicationPass is split into a
utility class, TailDuplicator, and the pass itself. The pass delegates
nearly everything to the TailDuplicator object, except for looping over
the blocks in a function. This allows the same code to be used for tail
duplication in both places.
This change, in concert with outlining optional branches, allows
triangle shaped code to perform much better, esepecially when the
taken/untaken branches are correlated, as it creates a second spine when
the tests are small enough.
Issue from previous rollback fixed, and a new test was added for that
case as well. Issue was worklist/scheduling/taildup issue in layout.
Issue from 2nd rollback fixed, with 2 additional tests. Issue was
tail merging/loop info/tail-duplication causing issue with loops that share
a header block.
Issue with early tail-duplication of blocks that branch to a fallthrough
predecessor fixed with test case: tail-dup-branch-to-fallthrough.ll
Differential revision: https://reviews.llvm.org/D18226
llvm-svn: 283934
2016-10-12 04:36:43 +08:00
|
|
|
br i1 %switch, label %for.cond, label %for.end
|
|
|
|
|
|
|
|
for.end: ; preds = %dup1
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
attributes #0 = { uwtable }
|