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

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

https://gcc.gnu.org/g:410675cb63466d8de9ad590521f0766b012d2475

commit r11-2103-g410675cb63466d8de9ad590521f0766b012d2475
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Wed Jul 15 11:26:22 2020 +0200

    builtins: Avoid useless char/short -> int promotions before atomics
[PR96176]

    As mentioned in the PR, we generate a useless movzbl insn before lock
cmpxchg.
    The problem is that the builtin for the char/short cases has the arguments
    promoted to int and combine gives up, because the instructions have
    MEM_VOLATILE_P arguments and recog in that case doesn't recognize anything
    when volatile_ok is false, and nothing afterwards optimizes the
    (reg:SI a) = (zero_extend:SI (reg:QI a))
    ... (subreg:QI (reg:SI a) 0) ...

    The following patch fixes it at expansion time, we already have a function
    that is meant to undo the promotion, so this just adds the very common case
    to that.

    2020-07-15  Jakub Jelinek  <ja...@redhat.com>

            PR target/96176
            * builtins.c: Include gimple-ssa.h, tree-ssa-live.h and
            tree-outof-ssa.h.
            (expand_expr_force_mode): If exp is a SSA_NAME with different mode
            from MODE and get_gimple_for_ssa_name is a cast from MODE, use the
            cast's rhs.

            * gcc.target/i386/pr96176.c: New test.

Reply via email to