llvm-project/llvm
Sanjay Patel d66607bd8c [CodeGenPrepare] use branch weight metadata to decide if a select should be turned into a branch
This is part of solving PR27344:
https://llvm.org/bugs/show_bug.cgi?id=27344

CGP should undo the SimplifyCFG transform for the same reason that earlier patches have used this
same mechanism: it's possible that passes between SimplifyCFG and CGP may be able to optimize the
IR further with a select in place.

For the TLI hook default, >99% taken or not taken is chosen as the default threshold for a highly
predictable branch. Even the most limited HW branch predictors will be correct on this branch almost
all the time, so even a massive mispredict penalty perf loss would be overcome by the win from all
the times the branch was predicted correctly.

As a follow-up, we could make the default target hook less conservative by using the SchedMachineModel's
MispredictPenalty. Or we could just let targets override the default by implementing the hook with that
and other target-specific options. Note that trying to statically determine mispredict rates for 
close-to-balanced profile weight data is generally impossible if the HW is sufficiently advanced. Ie, 
50/50 taken/not-taken might still be 100% predictable.

Finally, note that this patch as-is will not solve PR27344 because the current __builtin_unpredictable()
branch weight default values are 4 and 64. A proposal to change that is in D19435.

Differential Revision: http://reviews.llvm.org/D19488

llvm-svn: 267572
2016-04-26 17:11:17 +00:00
..
bindings Remove every uses of getGlobalContext() in LLVM (but the C API) 2016-04-14 21:59:01 +00:00
cmake When building with LLVM_ENABLE_MODULES, put the module cache into the build 2016-04-17 20:58:01 +00:00
docs [ppc64] Reenable sibling call optimization on ppc64 since fixed tsan library tail-call issue 2016-04-26 07:38:24 +00:00
examples Remove every uses of getGlobalContext() in LLVM (but the C API) 2016-04-14 21:59:01 +00:00
include [CodeGenPrepare] use branch weight metadata to decide if a select should be turned into a branch 2016-04-26 17:11:17 +00:00
lib [CodeGenPrepare] use branch weight metadata to decide if a select should be turned into a branch 2016-04-26 17:11:17 +00:00
projects
resources
test [CodeGenPrepare] use branch weight metadata to decide if a select should be turned into a branch 2016-04-26 17:11:17 +00:00
tools Refactor some more PDB reading code into DebugInfoPDB. 2016-04-26 16:20:00 +00:00
unittests Use gcc's rules for parsing gcc-style response files 2016-04-26 13:53:56 +00:00
utils Add natvis visualizers for endian types. 2016-04-21 20:58:41 +00:00
.arcconfig
.clang-format
.clang-tidy Don't use misc-unused-parameters check on LLVM. 2016-04-13 08:58:52 +00:00
.gitignore
CMakeLists.txt Moving llvm-test-depends and test-depends into the Tests folder; NFC, this simply cleans up the generated solution so that these targets don't live in the root folder of the IDE. 2016-04-12 15:09:14 +00:00
CODE_OWNERS.TXT Update owners to reflect recent changes 2016-04-01 20:40:49 +00:00
CREDITS.TXT
LICENSE.TXT Update copyright year to 2016. 2016-03-30 22:41:06 +00:00
LLVMBuild.txt
README.txt
configure
llvm.spec.in

README.txt

Low Level Virtual Machine (LLVM)
================================

This directory and its subdirectories contain source code for LLVM,
a toolkit for the construction of highly optimized compilers,
optimizers, and runtime environments.

LLVM is open source software. You may freely distribute it under the terms of
the license agreement found in LICENSE.txt.

Please see the documentation provided in docs/ for further
assistance with LLVM, and in particular docs/GettingStarted.rst for getting
started with LLVM and docs/README.txt for an overview of LLVM's
documentation setup.

If you are writing a package for LLVM, see docs/Packaging.rst for our
suggestions.