[Bug tree-optimization/55869] New: different bit shift/or optimization.
pluto at agmk dot net
gcc-bugzilla@gcc.gnu.org
Thu Jan 3 20:13:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55869
Bug #: 55869
Summary: different bit shift/or optimization.
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: pluto@agmk.net
here're equvialent functions:
$ cat u.cpp
unsigned long long convert_1( bool flag )
{
return (unsigned long long)(flag ? 1ull : 0ull) << 57;
}
unsigned long long convert_2( bool flag )
{
return (unsigned long long)flag << 57;
}
current 4.7/4.8 gcc emits following different machine code:
_Z9convert_1b:
testb %dil, %dil # 29 *cmpqi_ccno_1/1 [length = 3]
movl $0, %edx # 32 *movdi_internal_rex64/1 [length = 5]
movabsq $144115188075855872, %rax # 28 *movdi_internal_rex64/3
[length = 10]
cmove %rdx, %rax # 31 *movdicc_noc/1 [length = 4]
ret # 39 simple_return_internal [length = 1]
_Z9convert_2b:
movq %rdi, %rax # 19 *movdi_internal_rex64/2 [length = 3]
salq $57, %rax # 8 *ashldi3_1/1 [length = 4]
ret # 27 simple_return_internal [length = 1]
while clang/llvm emits equivalent machine code for both functions:
_Z9convert_1b: # @_Z9convert_1b
movzbl %dil, %eax
shlq $57, %rax
ret
_Z9convert_2b: # @_Z9convert_2b
movzbl %dil, %eax
shlq $57, %rax
ret
More information about the Gcc-bugs
mailing list