<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Using bitwise-or versus logical-or on boolean values produces different assembly at -O3"
   href="http://llvm.org/bugs/show_bug.cgi?id=22723">22723</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Using bitwise-or versus logical-or on boolean values produces different assembly at -O3
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>rtrieu@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Compare:

  bool test(bool x, bool y) {
    return !x | !y;
  }

And:

  bool test(bool x, bool y) {
    return !x || !y;
  }

which only differ in that the first uses a bitwise-or while the second uses a
logical-or.  Since the values are bool, both functions should produce the same
result.  However, different assembly is produced when compiled with Clang at
-O3.

Bitwise function:
    .text
    .file    "bool1.cc"
    .globl    _Z4testbb
    .align    16, 0x90
    .type    _Z4testbb,@function
_Z4testbb:                              # @_Z4testbb
    .cfi_startproc
# BB#0:                                 # %entry
    movzbl    %dil, %ecx
    xorl    $1, %ecx
    movzbl    %sil, %eax
    xorl    $1, %eax
    orl    %ecx, %eax
                                        # kill: AL<def> AL<kill> EAX<kill>
    retq
.Ltmp0:
    .size    _Z4testbb, .Ltmp0-_Z4testbb
    .cfi_endproc


    .ident    "clang version 3.7.0 (trunk 230662)"
    .section    ".note.GNU-stack","",@progbits

Logical function:
    .text
    .file    "bool2.cc"
    .globl    _Z4testbb
    .align    16, 0x90
    .type    _Z4testbb,@function
_Z4testbb:                              # @_Z4testbb
    .cfi_startproc
# BB#0:                                 # %entry
    andb    %sil, %dil
    xorb    $1, %dil
    movb    %dil, %al
    retq
.Ltmp0:
    .size    _Z4testbb, .Ltmp0-_Z4testbb
    .cfi_endproc


    .ident    "clang version 3.7.0 (trunk 230662)"
    .section    ".note.GNU-stack","",@progbits</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>