[Patch] libstdc++/23425

Paolo Carlini pcarlini@suse.de
Tue Nov 1 13:53:00 GMT 2005


Hi,

I think it makes perfect sense to apply the simple patch submitted as
part of the PR: in case of clear() we know a lot more of a generic
erase(iterator, iterator) and, indeed, "manually inlining" the current
erase call and cleaning up the result we end up with the very same code
of ~vector() (+ adjustment for the _M_finish pointer). The impact on the
generated assembly is impressive (x86, -O2 -fomit-frame-pointer):

00000000 <clear1()>:
   0:   a1 00 00 00 00          mov    0x0,%eax
   5:   a3 04 00 00 00          mov    %eax,0x4
   a:   c3                      ret

00000010 <clear2()>:
  10:   83 ec 1c                sub    $0x1c,%esp
  13:   8b 15 04 00 00 00       mov    0x4,%edx
  19:   8d 44 24 18             lea    0x18(%esp),%eax
  1d:   89 04 24                mov    %eax,(%esp)
  20:   89 54 24 0c             mov    %edx,0xc(%esp)
  24:   8b 15 00 00 00 00       mov    0x0,%edx
  2a:   89 54 24 08             mov    %edx,0x8(%esp)
  2e:   ba 00 00 00 00          mov    $0x0,%edx
  33:   89 54 24 04             mov    %edx,0x4(%esp)
  37:   e8 fc ff ff ff          call   38 <clear2()+0x28>
  3c:   83 ec 04                sub    $0x4,%esp
  3f:   83 c4 1c                add    $0x1c,%esp
  42:   c3                      ret

Tested x86-linux. Will wait 'til tomorrow in case of contrary opinions.

Paolo.

//////////////////
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CL_23425
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20051101/587a1bb9/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch_23425
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20051101/587a1bb9/attachment-0001.ksh>


More information about the Libstdc++ mailing list