This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Performance regression
- From: Michael Matz <matz at suse dot de>
- To: Roger Sayle <roger at eyesopen dot com>
- Cc: Jim Wilson <wilson at redhat dot com>,Dale Johannesen <dalej at apple dot com>, <gcc at gcc dot gnu dot org>,<gcc-patches at gcc dot gnu dot org>
- Date: Wed, 25 Sep 2002 18:25:08 +0200 (CEST)
- Subject: Re: Performance regression
Hi,
On Wed, 25 Sep 2002, Roger Sayle wrote:
> My list includes simplify_unary_operation support for replacing zero
> and sign extension of memory oprands with subregs, and tweaking some
> of my constant-folding of AND_EXPRs to use SUBREGs instead of zero or
> sign extension when its known the top bits will be masked/ignored.
> Anything else that I'm obviously missing?
Think about the following code:
int i;
char *a;
... /* initialize i */
for (; i < 10; i++)
use (a[i]);
Suppose that int is 32bit and pointers are 64 bit. This would result in
something like this RTL:
p4:DI <= 'a'
L1: jmp L2 if p1:SI < 10
p2:DI <= sign_extend(p1)
p3:QI <= mem[p4:DI + p2:DI]
p1:SI ++
jmp L1
L2:
The actual sign_extend can be moved out of the loop, if one changes the
width of pseudo p1, in which case p1 and p2 can be coalesced (or if one
increments p2 too). For this one needs to be able to see, that a
certain pseudo remains the sign extension of a different pseudo, even
if changed in different ways. This would result in something like
(without widening p1):
p4:DI <= 'a'
p2:DI <= sign_extend(p1)
L1: jmp L2 if p1:SI < 10
p3:QI <= mem[p4:DI + p2:DI]
p1:SI++
p2:DI++
jmp L1
L2
A later pass would observe that p1 and p2 have the same values everywhere,
and delete one of them. To implement something like this we would need to
handle sign/zero-extensions with PRE, and possibly some custom code to
widen pseudos and use subregs for those places, where really the original
mode is needed.
The above transformation is also valid (for C and C++) if nothing is known
about the upper bound, as for the equalitity of p1 and p2 to not hold it
is necessary that a wrap around happens in one of the increments, which is
undefined for signed ints.
Ciao,
Michael.