This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Additional patch to further improve delete_computation.
- To: John Wehle <john at feith dot com>
- Subject: Re: Additional patch to further improve delete_computation.
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Mon, 23 Aug 1999 23:33:49 -0600
- cc: gcc-patches at gcc dot gnu dot org
- Reply-To: law at cygnus dot com
In message <199908082226.SAA26637@jwlab.FEITH.COM>you write:
> This patch allows delete_computation to remove calls to constant
> functions. For example using -O2 -fno-schedule-insns2 on a x86
> platform to compile:
>
> long
> func(long long a, long long b)
> {
> long long c;
>
> c = a / b;
>
> if (c)
> return 0;
>
> c -= c;
>
> return c;
> }
>
> without the patch produces:
>
> pushl %ebp
> movl %esp,%ebp
> subl $8,%esp
> movl 16(%ebp),%eax
> movl 20(%ebp),%edx
> pushl %edx
> pushl %eax
> movl 8(%ebp),%eax
> movl 12(%ebp),%edx
> pushl %edx
> pushl %eax
> call __divdi3
> xorl %eax,%eax
> leave
> ret
>
> with the patch:
>
> pushl %ebp
> movl %esp,%ebp
> subl $8,%esp
> movl 16(%ebp),%eax
> movl 20(%ebp),%edx
> pushl %edx
> pushl %eax
> movl 8(%ebp),%eax
> movl 12(%ebp),%edx
> pushl %edx
> pushl %eax
> xorl %eax,%eax
> leave
> ret
>
> This patch passes make bootstrap and make check on FreeBSD-3.2 x86.
>
> Notes:
>
> 1) Unfortunately at the moment I don't see a straight forward way
> to avoid pushing the arguements on the stack (helpful little
> things such as REG_LIBCALL and REG_RETVAL notes are not around),
> however with enough analysis it's probably doable.
>
> ChangeLog:
>
> Sun Aug 8 00:03:55 EDT 1999 John Wehle (john@feith.com)
>
> * jump.c (delete_prior_computation): Also check calls
> to constant functions. Don't bother checking for a
> REG_UNUSED note before adding it.
> (delete_computation): Handle multi-word hard registers
> when synthesizing missing REG_DEAD notes for a register
> which is both set and used by an insn.
I think we've already got the multi-word hard register stuff installed and
note synthesis installed. Right?
Can you resubmit with just the new stuff. I suspect it'll be fine, but it's
just easier for me to read and evaluate.
On the subject of killing argument stores -- for machines which do not push
args, but instead use reg+d stores, local dead code elimination has a
reasonable
chance at eliminating the useless stores. Global dead store elimination is in
the works, which should allow us to do a pretty good job on those targets.
[ Global dead store elimination is just gcse/lcm run on the reverse flow
graph :-) ]
For machines which do push arguments, one could write a relatively simple
optimizer that looked for arg pushes followed by a stack pointer adjustment
without a call separating them and eliminate the pushes & stack pointer
adjustment. That (of course) would be a separate patch :-)
jeff