<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hi Nat!,</div><div class=""><br class=""></div><div class="">I think you can try to attach branch weight metadata to the branch or switch, and give a higher weight to the likely taken path. In that way, LLVM should be able to order the code correctly.</div><div class=""><br class=""></div><div class="">For branch weight metadata, you can refer to the following document:</div><div class=""><br class=""></div><div class=""><a href="http://llvm.org/docs/BranchWeightMetadata.html" class="">http://llvm.org/docs/BranchWeightMetadata.html</a></div><div class=""><br class=""></div><div class="">thanks,</div><div class="">chen </div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Oct 27, 2015, at 10:55 AM, Nat! via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">If I read the llvm language correctly, it doesn't have a way to specify the preferred branch, correct ? I see nothing in the specs for "branch" or "switch". And __buildin_expect does nothing, that I am sure of.<br class=""><br class="">Unfortunately llvm has this knack for ordering my one most crucial part of code exactly the opposite I want to, it does: (x86_64)<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">      </span>cmpq<span class="Apple-tab-span" style="white-space:pre">        </span>%r15, (%rax,%rdx)<br class=""><span class="Apple-tab-span" style="white-space:pre">      </span>jne<span class="Apple-tab-span" style="white-space:pre"> </span>LBB0_3<br class="">Ltmp18:<br class=""><span class="Apple-tab-span" style="white-space:pre">     </span>leaq<span class="Apple-tab-span" style="white-space:pre">        </span>8(%rax,%rdx), %rcx<br class=""><span class="Apple-tab-span" style="white-space:pre">     </span>jmp<span class="Apple-tab-span" style="white-space:pre"> </span>LBB0_4<br class="">LBB0_3:<br class=""><span class="Apple-tab-span" style="white-space:pre">     </span>addq<span class="Apple-tab-span" style="white-space:pre">        </span>$8, %rcx<br class="">LBB0_4:<br class=""><br class=""><br class=""><br class="">when I want,<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">      </span>cmpq<span class="Apple-tab-span" style="white-space:pre">        </span>%r15, (%rax,%rdx)<br class=""><span class="Apple-tab-span" style="white-space:pre">      </span>jeq<span class="Apple-tab-span" style="white-space:pre"> </span>LBB0_3<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">    </span>addq<span class="Apple-tab-span" style="white-space:pre">        </span>$8, %rcx<br class=""><span class="Apple-tab-span" style="white-space:pre">       </span>jmp<span class="Apple-tab-span" style="white-space:pre"> </span>LBB0_4<br class="">LBB0_3:<br class=""><span class="Apple-tab-span" style="white-space:pre">     </span>leaq<span class="Apple-tab-span" style="white-space:pre">        </span>8(%rax,%rdx), %rcx<br class="">LBB0_4:<br class=""><br class="">since that saves me executing a jump 99.9% of the time. Is there anything I can do ?<br class=""><br class="">Ciao<br class="">   Nat!<br class="">_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""></div></blockquote></div><br class=""></body></html>