Proposal for SentinelInputRange

Dmitry Olshansky dmitry.olsh at gmail.com
Thu Feb 28 10:02:37 PST 2013


28-Feb-2013 21:38, deadalnix пишет:
> On Thursday, 28 February 2013 at 17:13:36 UTC, Dmitry Olshansky wrote:
>> No as a compiler will take it (or may depending on its brain) that 0
>> is what you want to test *first*. It may speed things up if branch is
>> almost always taken but its not the case with sentinel. Thus its jsut
>> dead code that needs to be decoded, evalutated and skipped (as
>> predicated) *before* doing switch jump.
>>
>> In fact some people avoid the overhead of switch by placing one or two
>> of highly-frequent branches with tests before the switch (thus
>> avoiding indirect branch it entails in these frequent cases).
>
> That won't work as expected with LLVM and full optimizations, as it will
> combine everything in a switch, unless you use branch weight, in which
> case it can do the reverse : extract common cases from the switch.
>
> See : http://llvm.org/docs/BranchWeightMetadata.html
>
Mn I missed this point. Seems cool unlike relying on it doing magic 
behind the senescence. Then I stand corrected.

> GCC does something similar.
>



-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list