https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96151

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Sandiford <rsand...@gcc.gnu.org>:

https://gcc.gnu.org/g:510125d2272175f47b26227fbe9b8c8c5abfd988

commit r11-2023-g510125d2272175f47b26227fbe9b8c8c5abfd988
Author: Richard Sandiford <richard.sandif...@arm.com>
Date:   Fri Jul 10 19:06:46 2020 +0100

    expr: Move reduce_bit_field target mode check [PR96151]

    In some cases, expand_expr_real_2 prefers to use the mode of the
    caller-suggested target instead of the mode of the expression when
    passing values to reduce_to_bit_field_precision.  E.g.:

          else if (target == 0)
            op0 = convert_to_mode (mode, op0,
                                   TYPE_UNSIGNED (TREE_TYPE
                                                  (treeop0)));
          else
            {
              convert_move (target, op0,
                            TYPE_UNSIGNED (TREE_TYPE (treeop0)));
              op0 = target;
            }

    where âop0â might not have âmodeâ for the âelseâ branch,
    but does for all the others.

    reduce_to_bit_field_precision discards the suggested target if it
    has the wrong mode.  This patch moves that to expand_expr_real_2
    instead (conditional on reduce_bit_field).

    gcc/
            PR middle-end/96151
            * expr.c (expand_expr_real_2): When reducing bit fields,
            clear the target if it has a different mode from the expression.
            (reduce_to_bit_field_precision): Don't do that here.  Instead
            assert that the target already has the correct mode.

Reply via email to