<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:spatel+llvm@rotateright.com" title="Sanjay Patel <spatel+llvm@rotateright.com>"> <span class="fn">Sanjay Patel</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - bad generated code for conditionals connected by (&)"
   href="https://llvm.org/bugs/show_bug.cgi?id=23827">bug 23827</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>REOPENED
           </td>
           <td>RESOLVED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>---
           </td>
           <td>INVALID
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - bad generated code for conditionals connected by (&)"
   href="https://llvm.org/bugs/show_bug.cgi?id=23827#c19">Comment # 19</a>
              on <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - bad generated code for conditionals connected by (&)"
   href="https://llvm.org/bugs/show_bug.cgi?id=23827">bug 23827</a>
              from <span class="vcard"><a class="email" href="mailto:spatel+llvm@rotateright.com" title="Sanjay Patel <spatel+llvm@rotateright.com>"> <span class="fn">Sanjay Patel</span></a>
</span></b>
        <pre>As of:
<a href="http://reviews.llvm.org/rL246699">http://reviews.llvm.org/rL246699</a>

...we can use "__builtin_unpredictable()" to get the desired single branch
codegen from either of the ampamp() or amp() test cases:

void ampamp(int x, int y) {
  if (__builtin_unpredictable(x < 3 && y > 10) ) 
    printf("%d%d", x, y);
}

void amp(int x, int y) {
  if (__builtin_unpredictable((x < 3) & (y > 10)) ) 
    printf("%d%d", x, y);
}

$ ./clang -O2 -fomit-frame-pointer -S -o - 23827.c 
...
## BB#0:                                ## %entry
    movl    %esi, %r8d
    movl    %edi, %edx
    cmpl    $3, %edx
    setl    %al
    cmpl    $10, %r8d
    setg    %cl
    andb    %al, %cl
    movzbl    %cl, %eax
    cmpl    $1, %eax
    jne    LBB0_1
## BB#2:                                ## %if.then
    leaq    L_.str(%rip), %rdi
    xorl    %eax, %eax
    movl    %edx, %esi
    movl    %r8d, %edx
    jmp    _printf                 ## TAILCALL
LBB0_1:                                 ## %if.end
    retq

-------------------------------------------------------------------------

I'm resolving this as 'invalid' because the request to change codegen in the
original test is not something we can do. Please reopen if you still disagree.
If there are problems with the less branchy codegen after using
'unpredictable', please file a new bug.

I filed <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - SimplifyCFG may de-optimize code with highly predictable branches"
   href="show_bug.cgi?id=24743">bug 24743</a> to track the problem mentioned in <a href="show_bug.cgi?id=23827#c1">comment 1</a> / <a href="show_bug.cgi?id=23827#c7">comment 7</a>.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>