This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: random thought - optimizer


On Tue, 3 Jul 2001, Joe Buck wrote:

> Jeff writes:
> > If/when there's a way to tell that a MEM is local to a procedure, then it
> > is trivial for our SSA DCE optimizer to remove loads/stores to that variable
> > if they do not contribute to the externally visible result of the program.
>
> Terrific.  This possibly has the potential to get rid of a major g++
> performance problem: when a temporary object with two or more fields
> is passed by an inline function, we almost always wind up with dead
> stores (ADDRESSOF takes care of the one-field case).  Can the SSA
> DCE optimizer kill the dead stores?  Here's an example of a typical
> case -- a bit vector with an overloaded [] operator where the operator[]
> returns a proxy object:

I have a much worse example of this as PR/2399.

About 20 dead stores into 120 bytes of stack frame; when it should be a
single instruction.

As there's so much obvious cruft there, it may be easier to use this as a
testcase.


<bar__FGQ2t13D3VolumeIndex2ZcZt13D3VolumeFixed4Zci16i16i16_5Index>:
                  90: 83 ec 78 			sub $0x78,%esp
                  93: 53 			push %ebx
                  94: 8b 9c 24 80 00 00 00 	mov 0x80(%esp,1),%ebx
                  9b: 89 5c 24 30 		mov %ebx,0x30(%esp,1)
                  9f: 8b 8c 24 84 00 00 00 	mov 0x84(%esp,1),%ecx
                  a6: 89 4c 24 34 		mov %ecx,0x34(%esp,1)
                  aa: 8b 94 24 88 00 00 00	mov 0x88(%esp,1),%edx
                  b1: 89 54 24 38 		mov %edx,0x38(%esp,1)
                  b5: 8b 84 24 8c 00 00 00 	mov 0x8c(%esp,1),%eax
                  bc: 89 44 24 3c 		mov %eax,0x3c(%esp,1)
                  c0: 89 5c 24 44 		mov %ebx,0x44(%esp,1)
                  c4: 89 4c 24 48 		mov %ecx,0x48(%esp,1)
                  c8: 89 54 24 4c 		mov %edx,0x4c(%esp,1)
                  cc: 89 44 24 50 		mov %eax,0x50(%esp,1)
                  d0: c7 44 24 54 05 00 00 	movl $0x5,0x54(%esp,1)
                  d7: 00
                  d8: 89 5c 24 14 		mov %ebx,0x14(%esp,1)
                  dc: 89 4c 24 18 		mov %ecx,0x18(%esp,1)
                  e0: 89 54 24 1c 		mov %edx,0x1c(%esp,1)
                  e4: 89 44 24 20 		mov %eax,0x20(%esp,1)
                  e8: 89 5c 24 58 		mov %ebx,0x58(%esp,1)
                  ec: 89 4c 24 5c 		mov %ecx,0x5c(%esp,1)
                  f0: 89 54 24 60 		mov %edx,0x60(%esp,1)
                  f4: 89 44 24 64 		mov %eax,0x64(%esp,1)
                  f8: c7 44 24 68 05 00 00 	movl $0x5,0x68(%esp,1)
                  ff: 00
                  100: c7 44 24 6c 04 00 00 	movl $0x4,0x6c(%esp,1)
                  107: 00
                  108: c6 80 45 03 00 00 0a 	movb $0xa,0x345(%eax)
                  10f: 5b 			pop %ebx
                  110: 83 c4 78 		add $0x78,%esp
                  113: c3 			ret


Only the last store 'movb $0xa,0x345(%eax)' is live.

This was tested on 2.95.2, and has been sitting around unreviewed
for about 3 months.

Scott



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]