[LLVMbugs] [Bug 22723] New: Using bitwise-or versus logical-or on boolean values produces different assembly at -O3
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Feb 26 19:38:43 PST 2015
http://llvm.org/bugs/show_bug.cgi?id=22723
Bug ID: 22723
Summary: Using bitwise-or versus logical-or on boolean values
produces different assembly at -O3
Product: new-bugs
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: rtrieu at google.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
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, at 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","", at progbits
Logical function:
.text
.file "bool2.cc"
.globl _Z4testbb
.align 16, 0x90
.type _Z4testbb, at 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","", at progbits
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150227/6ec339a0/attachment.html>
More information about the llvm-bugs
mailing list