This is the mail archive of the gcc@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]

[tree-ssa]: The dangers of keeping constants in phi nodes


If you rewrite a var which had a constant propagated into a phi node, it loses the phi node value (IE it never unpropagates it temporarily, or remembers it was there), and thus, you lose the initialization.

There is no warning that this occurred, and unless you noticed it otherwise, it's not easy to catch.

This is clearly a bug.

Try the following code, and mark I and J for renaming again at some point after dom opts.
You'll see that it I and J will no longer be initialized to 0 anymore, and the output code won't run properly.


int main(void)
{
        int I, J;
        const int N = 30;
        const int M = 40;
        for (J = 0; J < N; J++)
        {
                for (I = 0; I < M; I++)
                {
                        printf ("%d %d\n", I, J);
                }
        }
}

I'm not sure what the right solution is here, but the current situation, expecting clients to know that variables they rewrite might be set to a constant in some phi node somewhere, and thus, you need to deal with that, seems wrong.
rewrite_into_ssa needs to notice this, and take care of it.


--Dan


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