This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
improving auto increment expressions detection across basic blocks.
- From: "Ramana Radhakrishnan" <ramana dot r at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 7 Apr 2008 11:31:04 +0100
- Subject: improving auto increment expressions detection across basic blocks.
Hi ,
I've been looking to sort out a case where one sees the possibility of
doing some kind of redundancy elimination with auto-increment
expressions across basic blocks. I understand based on earlier
conversations as well as looking at auto-inc-dec.c that all
infrastructure for auto-inc-dec works only in one basic block. Looking
at a number of loops in a codec and other internal benchmarks I notice
that looking at auto-increments outside of a basic block loop would
help cases where you have a possibility of merging the auto-increment
for the
The basic case is as explained below.
for (i = 0; i < 100; i ++)
{
if (....)
{
a[i] = something;
}
else
a[i] = something else..
}
The specific testcase I have is the following where you can see that
void Test (int n, int out[], int in[])
{
int i;
for (i = 0; i < n; i++) {
if (in[i]) {
out[i] = 0x12;
} else {
out[i] = 0x98;
}
}
}
Test:
cmpslt $c6,$zero,$c1
brz $c6,$link
incsi $c1,-1
i2cs $c4,152
i2cs $c5,18
.L5:
ldw $c6,($c3[0])
briz $c6,.L3
stw ($c2[0]),$c5
.L4:
addzi $c3,$c3,4.... This can be merged with the load above
to remove this extra addition and can be used with auto increment.
addzi $c2,$c2,4 ... This has the potential of being merged
with the above store instruction.
brinzdec $c1,.L5
brz $zero,$link
.L3:
stw ($c2[0]),$c4
briz $zero,.L4
The code generated does not use a post increment operation for the
address calculation for out where we could very well have done so. I
am wondering if there could be a pass after the current local auto
increment spotter which does this detection and improvement across
basic blocks. I am not clear where one could do this and how to
improve this particular case of code generation. Any suggestions would
be most helpful.
cheers
Ramana
--
Ramana Radhakrishnan