The following two functions are not if-converted at the tree level (the 2nd example happens a lot from VEC code via VEC_BASE): int *bar (char *p) { int *q; if (p) q = (int *)p; else q = (int *)0; return q; } struct X { int q; }; int *foo (struct X *p) { int *q; if (p) q = &p->q; else q = (int *)0; return q; } before phiopt1 we have bar (char * p) { int * q; <bb 2>: if (p_2(D) != 0B) goto <bb 3>; else goto <bb 4>; <bb 3>: q_3 = (int *) p_2(D); <bb 4>: # q_1 = PHI <q_3(3), 0B(2)> return q_1; which can be optimized to just <bb 2>: return (int *) p_2(D); well - with a separate stmt for the conversion.
Created attachment 19485 [details] testcase using vec.h
Both are handled correctly already. PR 51030 for foo. bar was fix in 4.6.0. I am just going to mark this as a dup of bug 51030. *** This bug has been marked as a duplicate of bug 51030 ***