[cfe-dev] [LLVMdev] bitwise ops on booleans

Sanjay Patel spatel at rotateright.com
Mon Jun 29 16:26:53 PDT 2015


> ----- Original Message -----
>> > From: "Chandler Carruth" <chandlerc at google.com>
>> > I don't have any problem teaching codegen to use very specific
>> > information to weigh the costs of an additional branch. But that
>> > needs to be done in codegen, as it is rare on x86 at this point that
>> > a well predicted branch is more expensive than anything, and given
>> > the quality of branch predictors on x86, it is also relatively rare
>> > that branches are so unpredictable.
>>
>
I agree that it's rare, but it's common enough that it makes some of our
very knowledgeable and perf-starved customers furious when LLVM
unilaterally declares that it knows best and turns all bit-logic into
branches.

At the least, I think this optimization needs a chicken switch because
there's no way we can know in advance that adding a branch will beat a
compound predicate in all cases. I attached a test program and some results
to PR23827. Feedback and more data points are certainly appreciated.

Also, we should be careful here: there's no provision for branch prediction
in the x86 arch. That's purely a micro-arch concept for x86 AFAIK. We don't
know what micro-arches will look like N years from now...even if they're
all excellent at prediction today.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150629/f042a148/attachment.html>


More information about the cfe-dev mailing list