[PATCH] D28249: Improve scheduling with branch coalescing
Lei Huang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 3 12:39:53 PST 2017
lei created this revision.
lei added reviewers: Carrot, nemanjai, kbarton, echristo.
lei added a subscriber: llvm-commits.
Herald added subscribers: mgorny, mehdi_amini, aemerson.
Improve scheduling by coalescing branches that depend on the same condition. This pass looks for blocks that are guarded by the same branch condition in the IR and attempts to merge the blocks together. This is done by moving code either up/down to it’s predecessor/successor blocks.
On power8 LE, we see a 11% improvement for lbm and 28% improvement for mcf (SPEC2006).
I tried the following test on ARM and X86.
$ cat branchC.ll
; RUN: llc -mcpu=generic -mtriple=x86_64-unknown-linux -verify-machineinstrs < %s | FileCheck %s
; RUN: llc -mtriple=armv6-unknown-linux-gnu < %s | FileCheck %s
; RUN: llc -verify-machineinstrs -o - %s -mtriple=aarch64-linux-gnu | FileCheck %s
; Function Attrs: nounwind
define double @testBranchCoal(double %a, double %b, double %c, i32 %x) {
entry:
%test = icmp eq i32 %x, 0
%tmp1 = select i1 %test, double %a, double 2.000000e-03
%tmp2 = select i1 %test, double %b, double 0.000000e+00
%tmp3 = select i1 %test, double %c, double 5.000000e-03
%res1 = fadd double %tmp1, %tmp2
%result = fadd double %res1, %tmp3
ret double %result
}
This does not affect ARM since the LLVM IR produced does not conform to the pattern we expected.
For X86, the branches were not coalesced since the terminator produced contain implicit operands. This code will only coalesce branches whose terminators contain explicit operands.
This is originally reported in: https://llvm.org/bugs/show_bug.cgi?id=25219
https://reviews.llvm.org/D28249
Files:
include/llvm/CodeGen/Passes.h
include/llvm/InitializePasses.h
lib/CodeGen/BranchCoalescing.cpp
lib/CodeGen/CMakeLists.txt
lib/CodeGen/CodeGen.cpp
lib/CodeGen/TargetPassConfig.cpp
test/CodeGen/PowerPC/branch_coalesce.ll
test/CodeGen/PowerPC/select-i1-vs-i1.ll
test/CodeGen/Thumb/select.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28249.82932.patch
Type: text/x-patch
Size: 34311 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170103/4c718f29/attachment.bin>
More information about the llvm-commits
mailing list