[PATCH] D13070: [SimplifyCFG] Speculatively flatten CFG based on profiling metadata
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 22 14:18:27 PDT 2015
reames created this revision.
reames added reviewers: hfinkel, sanjoy, majnemer.
reames added a subscriber: llvm-commits.
If we have a series of branches which are all unlikely to fail, we can possibly combine them into a single check on the fastpath combined with a bit of dispatch logic on the slowpath. We don't want to do this unconditionally since it requires speculating instructions past a branch, but if the profiling metadata on the branch indicates profitability, this can reduce the number of checks needed along the fast path.
The canonical example this is trying to handle is removing the second bounds check implied by the Java code: a[i] + a[i+1]. Note that it can currently only do so for really simple conditions and the values of a[i] can't be used anywhere except in the addition. (i.e. the load has to have been sunk already and not prevent speculation.) I plan on extending this transform over the next few days to handle alternate sequences.
Note that this builds on the "implies" function introduced in http://reviews.llvm.org/D13040. Please ignore its definition here and direct comments to that review. Based on Sanjoy's feedback, I'm going to introduce this logic into InstSimplify and refactor both patches based on that.
http://reviews.llvm.org/D13070
Files:
lib/Transforms/Utils/SimplifyCFG.cpp
test/Transforms/SimplifyCFG/fast-fallthrough.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13070.35416.patch
Type: text/x-patch
Size: 8482 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150922/be249335/attachment.bin>
More information about the llvm-commits
mailing list