On Thu, Dec 15, 2011 at 2:41 PM, Amker.Cheng <amker.ch...@gmail.com> wrote:
> HI,
> I encountered a case with below codes:
>
> int data_0;
> int motion_test1(int data, int v)
> {
>        int i;
>        int t, u;
>    int x;
>
>        if (data)
>                i = data_0 + x;
>        else {
>                v = 2;
>                i = 5;
>        }
>        t = data_0 + x;
>        u = i;
>        return v * t * u;
> }
> The dump file for 023t.ccp1 is like:
>
> motion_test1 (int data, int v)
> {
>  int x;
>  int t;
>  int D.4723;
>  int D.4722;
>  int data_0.0;
>
> <bb 2>:
>  if (data_3(D) != 0)
>    goto <bb 4>;
>  else
>    goto <bb 3>;
>
> <bb 3>:
>  v_8 = 2;
>
> <bb 4>:
>  # v_1 = PHI <v_7(D)(2), 2(3)>
>  data_0.0_10 = data_0;
>  t_11 = data_0.0_10 + x_5(D);
>  D.4723_13 = v_1 * t_11;
>  D.4722_14 = D.4723_13 * 5;
>  return D.4722_14;
>
> }
>
> Seems the result is computed as "v*(data_0+x)*5", which is wrong.
> The question is whether it is a bug or intended behavior due to
> unintialized "x"?
>
> Any tips is welcome. Thanks.

CCP is right.  When the path with the uninitialized use is entered
the value of i becomes undefined x + <undefined> is <undefined>
(not so, for example x * <undefined> which is well-defined for x == 0).
At the PHI node for i any <undefined> values on edges are ignored
so the only edge with a defined value (with value 5) is propagated.

Richard.

> --
> Best Regards.

Reply via email to