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

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

https://gcc.gnu.org/g:3fa4752e29a5b44219837ebad5bb09ec98af156e

commit r9-9462-g3fa4752e29a5b44219837ebad5bb09ec98af156e
Author: Richard Sandiford <richard.sandif...@arm.com>
Date:   Sun Apr 25 14:51:14 2021 +0100

    vect: Avoid generating out-of-range shifts [PR98302]

    In this testcase we end up with:

      unsigned long long x = ...;
      char y = (char) (x << 37);

    The overwidening pattern realised that only the low 8 bits
    of x << 37 are needed, but then tried to turn that into:

      unsigned long long x = ...;
      char y = (char) x << 37;

    which gives an out-of-range shift.  In this case y can simply
    be replaced by zero, but as the comment in the patch says,
    it's kind-of awkward to do that in the middle of vectorisation.

    Most of the overwidening stuff is about keeping operations
    as narrow as possible, which is important for vectorisation
    but could be counter-productive for scalars (especially on
    RISC targets).  In contrast, optimising y to zero in the above
    feels like an independent optimisation that would benefit scalar
    code and that should happen before vectorisation.

    gcc/
            PR tree-optimization/98302
            * tree-vect-patterns.c (vect_determine_precisions_from_users): Make
            sure that the precision remains greater than the shift count.

    gcc/testsuite/
            PR tree-optimization/98302
            * gcc.dg/vect/pr98302.c: New test.

    (cherry picked from commit 58a12b0eadac62e691fcf7325ab2bc2c93d46b61)
  • [Bug target/98302] [9 Regressio... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to