<div dir="ltr">Do you have a test case?<div><br></div><div>David</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 26, 2016 at 8:11 PM, James Knight via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This change is broken in some fashion; it causes llvm to rewrite branches incorrectly producing an infinite loop.<br>
<div class="HOEnZb"><div class="h5"><br>
> On Jan 26, 2016, at 3:08 PM, Cong Hou via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br>
><br>
> Author: conghou<br>
> Date: Tue Jan 26 14:08:01 2016<br>
> New Revision: 258847<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=258847&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=258847&view=rev</a><br>
> Log:<br>
> Allow X86::COND_NE_OR_P and X86::COND_NP_OR_E to be reversed.<br>
><br>
> Currently, AnalyzeBranch() fails non-equality comparison between floating points<br>
> on X86 (see <a href="https://llvm.org/bugs/show_bug.cgi?id=23875" rel="noreferrer" target="_blank">https://llvm.org/bugs/show_bug.cgi?id=23875</a>). This is because this<br>
> function can modify the branch by reversing the conditional jump and removing<br>
> unconditional jump if there is a proper fall-through. However, in the case of<br>
> non-equality comparison between floating points, this can turn the branch<br>
> "unanalyzable". Consider the following case:<br>
><br>
> jne.BB1<br>
> jp.BB1<br>
> jmp.BB2<br>
> .BB1:<br>
> ...<br>
> .BB2:<br>
> ...<br>
><br>
> AnalyzeBranch() will reverse "jp .BB1" to "jnp .BB2" and then "jmp .BB2" will be<br>
> removed:<br>
><br>
> jne.BB1<br>
> jnp.BB2<br>
> .BB1:<br>
> ...<br>
> .BB2:<br>
> ...<br>
><br>
> However, AnalyzeBranch() cannot analyze this branch anymore as there are two<br>
> conditional jumps with different targets. This may disable some optimizations<br>
> like block-placement: in this case the fall-through behavior is enforced even if<br>
> the fall-through block is very cold, which is suboptimal.<br>
><br>
> Actually this optimization is also done in block-placement pass, which means we<br>
> can remove this optimization from AnalyzeBranch(). However, currently<br>
> X86::COND_NE_OR_P and X86::COND_NP_OR_E are not reversible: there is no defined<br>
> negation conditions for them.<br>
><br>
> In order to reverse them, this patch defines two new CondCode X86::COND_E_AND_NP<br>
> and X86::COND_P_AND_NE. It also defines how to synthesize instructions for them.<br>
> Here only the second conditional jump is reversed. This is valid as we only need<br>
> them to do this "unconditional jump removal" optimization.<br>
><br>
><br>
> Differential Revision: <a href="http://reviews.llvm.org/D11393" rel="noreferrer" target="_blank">http://reviews.llvm.org/D11393</a><br>
><br>
><br>
><br>
> Modified:<br>
>    llvm/trunk/lib/Target/X86/X86InstrInfo.cpp<br>
>    llvm/trunk/lib/Target/X86/X86InstrInfo.h<br>
>    llvm/trunk/test/CodeGen/X86/block-placement.ll<br>
>    llvm/trunk/test/CodeGen/X86/fast-isel-cmp-branch2.ll<br>
>    llvm/trunk/test/CodeGen/X86/fast-isel-cmp-branch3.ll<br>
>    llvm/trunk/test/CodeGen/X86/fp-une-cmp.ll<br>
><br>
<br>
</div></div><div class="HOEnZb"><div class="h5">_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div>