llvm/test/CodeGen/PowerPC/tail-dup-branch-to-fallthrough.ll
Kyle Butt 2a18018c10 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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283934 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-11 20:36:43 +00:00

66 lines
1.8 KiB
LLVM

; RUN: llc -O2 %s -o - | FileCheck %s
target datalayout = "E-m:e-i64:64-n32:64"
target triple = "powerpc64-unknown-linux-gnu"
; Function Attrs: nounwind
declare void @llvm.lifetime.end(i64, i8* nocapture) #0
declare void @f1()
declare void @f2()
declare void @f3()
declare void @f4()
; Function Attrs: nounwind
; CHECK-LABEL: tail_dup_fallthrough_with_branch
; CHECK: # %entry
; CHECK-NOT: # %{{[-_a-zA-Z0-9]+}}
; CHECK: # %entry
; CHECK-NOT: # %{{[-_a-zA-Z0-9]+}}
; CHECK: # %sw.0
; CHECK-NOT: # %{{[-_a-zA-Z0-9]+}}
; CHECK: # %sw.1
; CHECK-NOT: # %{{[-_a-zA-Z0-9]+}}
; CHECK: # %sw.default
; CHECK-NOT: # %{{[-_a-zA-Z0-9]+}}
; CHECK: # %if.then
; CHECK-NOT: # %{{[-_a-zA-Z0-9]+}}
; CHECK: # %if.else
; CHECK-NOT: # %{{[-_a-zA-Z0-9]+}}
; CHECK: .Lfunc_end0
define fastcc void @tail_dup_fallthrough_with_branch(i32 %a, i1 %b) unnamed_addr #0 {
entry:
switch i32 %a, label %sw.default [
i32 0, label %sw.0
i32 1, label %sw.1
]
sw.0: ; preds = %entry
call void @f1() #0
br label %dup1
sw.1: ; preds = %entry
call void @f2() #0
br label %dup1
sw.default: ; preds = %entry
br i1 %b, label %if.then, label %if.else
if.then: ; preds = %sw.default
call void @f3() #0
br label %dup2
if.else: ; preds = %sw.default
call void @f4() #0
br label %dup2
dup1: ; preds = %sw.0, %sw.1
call void @llvm.lifetime.end(i64 8, i8* nonnull undef) #0
unreachable
dup2: ; preds = %if.then, %if.else
call void @llvm.lifetime.end(i64 8, i8* nonnull undef) #0
unreachable
}
attributes #0 = { nounwind }