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

--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Roger Sayle <sa...@gcc.gnu.org>:

https://gcc.gnu.org/g:71197a5d13d0b540a9b5efe7ae2512d76386e9d1

commit r11-2621-g71197a5d13d0b540a9b5efe7ae2512d76386e9d1
Author: Roger Sayle <ro...@nextmovesoftware.com>
Date:   Sun Aug 9 23:14:58 2020 +0100

    middle-end: Correct calculation of mul_widen_cost and mul_highpart_cost.

    This patch fixes a subtle bug in the depths of GCC's synth_mult,
    where the middle-end queries whether (how well) the target supports
    widening and highpart multiplications by calling targetm.rtx_costs.
    The code in init_expmed and init_expmed_one_mode iterates over various
    RTL patterns querying the cost of each.  To avoid generating & garbage
    collecting too much junk, it reuses the same RTL over and over, but
    adjusting the modes between each call.

    Alas this reuse of state is a little fragile, and at some point a
    change to init_expmed_one_conv has resulted in the state (mode of
    a register) being changed, but not reset before being used again.

    Using the old software engineering/defensive programming maxim of
    "why fix a bug just once, if it can be fixed in multiple places",
    this patch both restores the original value in init_expmed_one_conv,
    and also sets it to the expected value in init_expmed_one_mode.
    This should hopefully signal the need to be careful of invariants for
    anyone modifying this code in future.

    2020-08-09  Roger Sayle  <ro...@nextmovesoftware.com>

    gcc/ChangeLog
            * expmed.c (init_expmed_one_conv): Restore all->reg's mode.
            (init_expmed_one_mode): Set all->reg to desired mode.

    gcc/testsuite/ChangeLog
            PR target/71321
            * gcc.target/i386/pr71321.c: Check that the code doesn't use
            the 4B zero displacement lea, not that it uses lea.

Reply via email to