[PATCH] Add a flag to experiment with outlining optional branches.
Xinliang David Li
xinliangli at gmail.com
Wed Mar 4 00:34:29 PST 2015
As I mentioned in the previous comment, LLVM's current block placement does
support outlining as in the following case:
START_A
if (__builtin_expect(cond,0)) {
UNLIKELY_B
}
JOIN_C
The layout order will be START_A JOIN_C UNLIKELY_B
It is just in order to break the topo-order, it requires a very strongly
biased branch (the cold target < 20% )
The alternatives include:
1) tune the threshold to break topo order
2) improve the static prediction in llvm.
David
On Wed, Mar 4, 2015 at 12:17 AM, Daniel Jasper <djasper at google.com> wrote:
> Ah right.
>
> Well, it might be too limiting, but it might be a good incremental step.
> Any further suggestions are definitely welcome.
>
> On Wed, Mar 4, 2015 at 9:04 AM, Xinliang David Li <xinliangli at gmail.com>
> wrote:
>
>> The example mentioned has a diamond shape. Besides within the 'then' arm
>> of cond1 branch, there could be multiple consecutive 'if (cond_x) B_x'
>> where B_x blocks are cold. The heuristic in your patch seems to be too
>> limiting.
>>
>> David
>>
>> On Tue, Mar 3, 2015 at 11:19 PM, Daniel Jasper <djasper at google.com>
>> wrote:
>>
>>> Yes. The reasoning is that in this case the entire branch (containing A,
>>> B and C) will already be outlined and we don't want to fragment this
>>> further. In initial benchmarks, this seemed to have a slight benefit over
>>> additionally outlining B. Lots of stuff we can investigate, though.
>>>
>>> On Wed, Mar 4, 2015 at 8:03 AM, Xinliang David Li <xinliangli at gmail.com>
>>> wrote:
>>>
>>>> If I read the change correctly, 'B' block in the following case can
>>>> not be outlined. Is it intended?
>>>>
>>>> David
>>>>
>>>> if (cond1) {
>>>> A
>>>> if (cond2) {
>>>>
>>>> B
>>>> }
>>>> C
>>>> ...
>>>> }
>>>> else {
>>>> D
>>>> }
>>>>
>>>> On Tue, Mar 3, 2015 at 10:46 PM, Daniel Jasper <djasper at google.com>
>>>> wrote:
>>>>
>>>>> Re-add the test.
>>>>>
>>>>>
>>>>> http://reviews.llvm.org/D7719
>>>>>
>>>>> Files:
>>>>> lib/CodeGen/MachineBlockPlacement.cpp
>>>>> test/CodeGen/X86/code_placement_outline_optional_branches.ll
>>>>>
>>>>> EMAIL PREFERENCES
>>>>> http://reviews.llvm.org/settings/panel/emailpreferences/
>>>>>
>>>>> _______________________________________________
>>>>> llvm-commits mailing list
>>>>> llvm-commits at cs.uiuc.edu
>>>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>>>>
>>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150304/2670d8ba/attachment.html>
More information about the llvm-commits
mailing list