<div dir="ltr">Nevermind. I figured it out.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 15, 2015 at 1:38 AM, Daniel Jasper <span dir="ltr"><<a href="mailto:djasper@google.com" target="_blank">djasper@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">What made you think it was this change that broke it? The test passed fine locally and still does if I re-apply the patch.</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 14, 2015 at 6:00 PM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">reverted because CodeGen/ARM/2013-10-11-select-stalls.ll was failing.<br>
<div><div><br>
On 14 April 2015 at 16:20, Daniel Jasper <<a href="mailto:djasper@google.com" target="_blank">djasper@google.com</a>> wrote:<br>
> Author: djasper<br>
> Date: Tue Apr 14 10:20:37 2015<br>
> New Revision: 234898<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=234898&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=234898&view=rev</a><br>
> Log:<br>
> The code that originally made me discover this is:<br>
><br>
>   if ((a & 0x1) == 0x1) {<br>
>     ..<br>
>   }<br>
><br>
> In this case we don't actually have any branch probability information and<br>
> should not assume to have any. LLVM transforms this into:<br>
><br>
>   %and = and i32 %a, 1<br>
>   %tobool = icmp eq i32 %and, 0<br>
><br>
> So, in this case, the result of a bitwise and is compared against 0,<br>
> but nevertheless, we should not assume to have probability<br>
> information.<br>
><br>
> Modified:<br>
>     llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp<br>
>     llvm/trunk/test/Analysis/BranchProbabilityInfo/basic.ll<br>
>     llvm/trunk/test/CodeGen/AArch64/arm64-call-tailcalls.ll<br>
>     llvm/trunk/test/CodeGen/Mips/octeon.ll<br>
><br>
> Modified: llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp?rev=234898&r1=234897&r2=234898&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp?rev=234898&r1=234897&r2=234898&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp (original)<br>
> +++ llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp Tue Apr 14 10:20:37 2015<br>
> @@ -379,6 +379,14 @@ bool BranchProbabilityInfo::calcZeroHeur<br>
>    if (!CV)<br>
>      return false;<br>
><br>
> +  // If the LHS is the result of AND'ing a value with a single bit bitmask,<br>
> +  // we don't have information about probabilities.<br>
> +  if (Instruction *LHS = dyn_cast<Instruction>(CI->getOperand(0)))<br>
> +    if (LHS->getOpcode() == Instruction::And)<br>
> +      if (ConstantInt *AndRHS = dyn_cast<ConstantInt>(LHS->getOperand(1)))<br>
> +        if (AndRHS->getUniqueInteger().isPowerOf2())<br>
> +          return false;<br>
> +<br>
>    bool isProb;<br>
>    if (CV->isZero()) {<br>
>      switch (CI->getPredicate()) {<br>
><br>
> Modified: llvm/trunk/test/Analysis/BranchProbabilityInfo/basic.ll<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BranchProbabilityInfo/basic.ll?rev=234898&r1=234897&r2=234898&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BranchProbabilityInfo/basic.ll?rev=234898&r1=234897&r2=234898&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/test/Analysis/BranchProbabilityInfo/basic.ll (original)<br>
> +++ llvm/trunk/test/Analysis/BranchProbabilityInfo/basic.ll Tue Apr 14 10:20:37 2015<br>
> @@ -212,3 +212,31 @@ exit:<br>
>    ret i32 %result<br>
>  }<br>
><br>
> +define i32 @zero3(i32 %i, i32 %a, i32 %b) {<br>
> +; CHECK: Printing analysis {{.*}} for function 'zero3'<br>
> +entry:<br>
> +; AND'ing with a single bit bitmask essentially leads to a bool comparison,<br>
> +; meaning we don't have probability information.<br>
> +  %and = and i32 %i, 2<br>
> +  %tobool = icmp eq i32 %and, 0<br>
> +  br i1 %tobool, label %then, label %else<br>
> +; CHECK: edge entry -> then probability is 16 / 32<br>
> +; CHECK: edge entry -> else probability is 16 / 32<br>
> +<br>
> +then:<br>
> +; AND'ing with other bitmask might be something else, so we still assume the<br>
> +; usual probabilities.<br>
> +  %and2 = and i32 %i, 5<br>
> +  %tobool2 = icmp eq i32 %and2, 0<br>
> +  br i1 %tobool2, label %else, label %exit<br>
> +; CHECK: edge then -> else probability is 12 / 32<br>
> +; CHECK: edge then -> exit probability is 20 / 32<br>
> +<br>
> +else:<br>
> +  br label %exit<br>
> +<br>
> +exit:<br>
> +  %result = phi i32 [ %a, %then ], [ %b, %else ]<br>
> +  ret i32 %result<br>
> +}<br>
> +<br>
><br>
> Modified: llvm/trunk/test/CodeGen/AArch64/arm64-call-tailcalls.ll<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/arm64-call-tailcalls.ll?rev=234898&r1=234897&r2=234898&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/arm64-call-tailcalls.ll?rev=234898&r1=234897&r2=234898&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/test/CodeGen/AArch64/arm64-call-tailcalls.ll (original)<br>
> +++ llvm/trunk/test/CodeGen/AArch64/arm64-call-tailcalls.ll Tue Apr 14 10:20:37 2015<br>
> @@ -53,9 +53,9 @@ bb:<br>
><br>
>  define i32 @t8(i32 %x) nounwind ssp {<br>
>  ; CHECK-LABEL: t8:<br>
> +; CHECK: b     _c<br>
>  ; CHECK: b     _a<br>
>  ; CHECK: b     _b<br>
> -; CHECK: b     _c<br>
>    %and = and i32 %x, 1<br>
>    %tobool = icmp eq i32 %and, 0<br>
>    br i1 %tobool, label %if.end, label %if.then<br>
><br>
> Modified: llvm/trunk/test/CodeGen/Mips/octeon.ll<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/octeon.ll?rev=234898&r1=234897&r2=234898&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/octeon.ll?rev=234898&r1=234897&r2=234898&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/test/CodeGen/Mips/octeon.ll (original)<br>
> +++ llvm/trunk/test/CodeGen/Mips/octeon.ll Tue Apr 14 10:20:37 2015<br>
> @@ -93,7 +93,7 @@ entry:<br>
>  ; ALL-LABEL: bbit0:<br>
>  ; OCTEON: bbit0   $4, 3, $[[BB0:BB[0-9_]+]]<br>
>  ; MIPS64: andi  $[[T0:[0-9]+]], $4, 8<br>
> -; MIPS64: beqz  $[[T0]], $[[BB0:BB[0-9_]+]]<br>
> +; MIPS64: bnez  $[[T0]], $[[BB0:BB[0-9_]+]]<br>
>    %bit = and i64 %a, 8<br>
>    %res = icmp eq i64 %bit, 0<br>
>    br i1 %res, label %endif, label %if<br>
> @@ -111,7 +111,7 @@ entry:<br>
>  ; MIPS64: daddiu  $[[T0:[0-9]+]], $zero, 1<br>
>  ; MIPS64: dsll    $[[T1:[0-9]+]], $[[T0]], 35<br>
>  ; MIPS64: and     $[[T2:[0-9]+]], $4, $[[T1]]<br>
> -; MIPS64: beqz    $[[T2]], $[[BB0:BB[0-9_]+]]<br>
> +; MIPS64: bnez    $[[T2]], $[[BB0:BB[0-9_]+]]<br>
>    %bit = and i64 %a, 34359738368<br>
>    %res = icmp eq i64 %bit, 0<br>
>    br i1 %res, label %endif, label %if<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>