This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/16611] Terrible code generated for vector<bool>
- From: "sabre at nondot dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Apr 2005 19:40:14 -0000
- Subject: [Bug tree-optimization/16611] Terrible code generated for vector<bool>
- References: <20040717215713.16611.falk@debian.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From sabre at nondot dot org 2005-04-11 19:40 -------
This code from stl_bvector.h is the problem:
void _M_incr(ptrdiff_t __i) {
difference_type __n = __i + _M_offset;
_M_p += __n / _M_word_bit;
__n = __n % _M_word_bit;
if (__n < 0) {
_M_offset = (unsigned int) __n + _M_word_bit;
--_M_p;
} else
_M_offset = (unsigned int) __n;
}
Note that the division and mod is performed on a signed __n value. If it were
unsigned, the optimizer could trivially turn it into shift/and ops.
-Chris
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |sabre at nondot dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16611