This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/27313] Does not emit conditional moves for stores
- From: "dwarak dot rajagopal at amd dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 25 Apr 2006 19:07:53 -0000
- Subject: [Bug middle-end/27313] Does not emit conditional moves for stores
- References: <bug-27313-11725@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from dwarak dot rajagopal at amd dot com 2006-04-25 19:07 -------
Yes this is true. The example I posted was a simplest case where it fails.
Below mmight be a typical case where you have to do two stores.
int cmov(int* A ,int B ,int C ,int* D ,int* E ,int F ,int g) {
int k,f;
for (k = 1; k <= 1000; k++) {
A[k] = B+C;
D[k] = C; /* D[k] may alias with A[k] */
g = D[k-1] + E[k-1];
if (g > A[k]) A[k]=g; /* This is not converted to cmov*/
f += g;
}
return f;
}
In this case, you cannot reduce the number of stores (becasue D[k] may alias
with A[k]) but you still want the if conversion to take place. I think it is
good to have a mechanism to track if a memory is already been written in ifcvt.
I'm not sure how it can be done at this level though.
-Dwarak
(In reply to comment #2)
> The other way of getting this is to have the code converted so there is only
> one store instead of two:
>
> int cmov(int* A ,int B ,int C ,int* D ,int* E ,int F ,int g) {
> int k,f;
> for (k = 1; k <= 1000; k++) {
> int t = B+C;
> g = D[k-1] + E[k-1];
> if (g > t) t=g; /* This is not converted to cmov*/
> A[K] = t;
> f += g;
> }
> return f;
> }
> Which is most likely better anyways as one it is smaller.
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27313