[PR71408] - Fix wrong code at -Os and above

Richard Biener richard.guenther@gmail.com
Mon Jun 6 08:57:00 GMT 2016


On Sun, Jun 5, 2016 at 12:54 PM, kugan
<kugan.vivekanandarajah@linaro.org> wrote:
> Hi All,
>
> For the testcase in PR71408 zero_one_operation seems still broken. In
> handling NEGATE_EXPR, as part of undistribute_ops_list, in
> zero_one_operation, we are doing propagate_op_to_single_use (op, stmt, def);
>
> This results in:
> -  _14 = _5 * _12;
>    _15 = (int) _11;
>    _16 = ~_15;
>    _17 = (unsigned int) _16;
> -  _18 = -_5;
> -  _19 = _17 * _18;
> -  _20 = _14 + _19;
> -  _24 = _5 & _20;
> +  _19 = _5 * _17;
> +  _35 = _19 + _12;
> +  _34 = _35 * _5;
> +  _20 = _34;
> +  _24 = _20 & _5;
>
> We should instead propagate (-1) as "op" is the one which gets factored out.
> With the attached patch we now have:
> -  _14 = _5 * _12;
>    _15 = (int) _11;
>    _16 = ~_15;
>    _17 = (unsigned int) _16;
> -  _18 = -_5;
> -  _19 = _17 * _18;
> -  _20 = _14 + _19;
> -  _24 = _5 & _20;
> +  _32 = _17;
> +  _19 = -_32;
> +  _34 = _19 + _12;
> +  _33 = _34 * _5;
> +  _20 = _33;
> +  _24 = _20 & _5;
>
> Regression tested and bootstrapped on x86-64-linux-gnu with no new
> regression. Is this OK for trunk?

Ok.

Thanks,
Richard.

> Thanks,
> Kugan
>
> gcc/ChangeLog:
>
> 2016-06-05  Kugan Vivekanandarajah  <kuganv@linaro.org>
>
>         PR middle-end/71408
>         * tree-ssa-reassoc.c (zero_one_operation): Fix NEGATE_EXPR operand
> for
>         propagate_op_to_single_use.
>
>
> gcc/testsuite/ChangeLog:
>
> 2016-06-05  Kugan Vivekanandarajah  <kuganv@linaro.org>
>
>         PR middle-end/71408
>         * gcc.dg/tree-ssa/pr71408.c: New test.
>
>
>



More information about the Gcc-patches mailing list