[Bug tree-optimization/30105] reassoc can sometimes get in the way of PRE

dberlin at dberlin dot org gcc-bugzilla@gcc.gnu.org
Tue Dec 12 16:49:00 GMT 2006



------- Comment #7 from dberlin at gcc dot gnu dot org  2006-12-12 16:49 -------
Subject: Re:  reassoc can sometimes get in the way of PRE

>
> Here is a slightly modified example that shows that there's still a PRE
> opportunity
>
> void motion_test22(int * data, int i)
> {
>   int j;
>   if (data[1]) {
>     data[data[2]] = 2;
>     j = data[0] *   data[3];
>     i = i *  j;
>   }
>   data[4] = data[0] * data[3];
>   data[5] = i;
> }
>
> <L0>:;
>   *((int *) ((unsigned int) *(data + 8B) * 4) + data) = 2;
>   prephitmp.26 = *data;
>   prephitmp.31 = *(data + 12B);
>   i = prephitmp.26 * i * prephitmp.31;
>
> <L1>:;
>   *(data + 16B) = prephitmp.31 * prephitmp.26;
>   *(data + 20B) = i;
>   return;
>
> There are 3 multiplications on the L0-L1 path. It should be possible
> to only have 2 multiplications on that path.

now *this* is a reassoc (or VN) problem.
It's not easy to see how to fix it, we can't always guess the right ordering.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30105



More information about the Gcc-bugs mailing list