[Bug target/46551] Generate complex addressing mode CMP instruction in x86-64

2011-06-21 Thread dgohman at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46551

Dan Gohman dgohman at gmail dot com changed:

   What|Removed |Added

 CC||dgohman at gmail dot com

--- Comment #2 from Dan Gohman dgohman at gmail dot com 2011-06-21 14:26:23 
UTC ---
Something has noticed that in the else block, a is equal to the value loaded
from vm-cell[vm-index[0] - 2], so it is replacing the use of a and CSE'ing it
with the loaded value. That's what causes the loaded value to have multiple
uses, which presumably is why GCC subsequently declines to fold the addresssing
into the compare.


[Bug libstdc++/44413] inefficient code for std::string::compare on x86-64

2010-06-08 Thread dgohman at gmail dot com


--- Comment #3 from dgohman at gmail dot com  2010-06-08 14:54 ---
Callers of compare are already exposed to __builtin_memcmp result values (with
default traits) which vary depending on the target and compiler flags.

And since _S_compare is only used as a tie-breaker after the memcmp, it's hard
to imagine any code innocently relying on it returning a particular value.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44413



[Bug libstdc++/44413] New: inefficient code for std::string::compare on x86-64

2010-06-04 Thread dgohman at gmail dot com
This code:

#include string
int foo(const std::string a, const std::string b) { return a.compare(b); }

compiles to code like this on x86-64:
[...]
subq%rdx, %r8
movl$2147483647, %eax
cmpq$2147483647, %r8
jg  .L2
movl$-2147483648, %eax
cmpq$-2147483648, %r8
cmovge  %r8d, %eax
.L2:
[...]

Since compare need only return a value greater, less, or equal to zero, the
code in _S_compare would be more efficient as simple code that just returns -1,
0, or 1 on most targets where difference_type is wider than int.


-- 
   Summary: inefficient code for std::string::compare on x86-64
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: enhancement
  Priority: P3
 Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dgohman at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44413