This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

[Bug middle-end/27313] Does not emit conditional moves for stores



------- 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


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