[PATCH] D12458: [clang] add __builtin_unpredictable and convert to metadata
Sanjay Patel via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 28 16:43:35 PDT 2015
spatel created this revision.
spatel added reviewers: hfinkel, kbsmith1, kparzysz, reames, silvas.
spatel added a subscriber: cfe-commits.
spatel added a dependency: D12341: add unpredictable metadata type for control flow.
This patch depends on D12341 ('unpredictable' metadata type for LLVM).
For now, I am ignoring the horrible thought that this builtin might take an extra parameter to distinguish different hardware. :)
The goal is to make LLVM generate different code for these functions for a target that has cheap branches (see PR23827 for more details):
int foo();
int normal(int x, int y, int z) {
if (x != 0 && y != 0) return foo();
return 1;
}
int crazy(int x, int y) {
if (__builtin_unpredictable(x != 0 && y != 0)) return foo();
return 1;
}
http://reviews.llvm.org/D12458
Files:
docs/LanguageExtensions.rst
include/clang/Basic/Builtins.def
lib/CodeGen/CGBuiltin.cpp
lib/CodeGen/CodeGenFunction.cpp
lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
test/CodeGen/builtin-unpredictable.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12458.33491.patch
Type: text/x-patch
Size: 6263 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150828/031c5a91/attachment.bin>
More information about the cfe-commits
mailing list