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

--- Comment #25 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jiu Fu Guo <guoji...@gcc.gnu.org>:

https://gcc.gnu.org/g:1aceceb1e2d6e86ce183c8cc448750fa03b6f79e

commit r14-3644-g1aceceb1e2d6e86ce183c8cc448750fa03b6f79e
Author: Jiufu Guo <guoji...@linux.ibm.com>
Date:   Mon Sep 4 10:31:04 2023 +0800

    Optimize '(X - N * M) / N' to 'X / N - M' if valid

    Integer expression "(X - N * M) / N" can be optimized to "X / N - M" with
    the below conditions:
    1. There is no wrap/overflow/underflow.
       wrap/overflow/underflow breaks the arithmetic operation.
    2. "X - N * M" and "X" are not of opposite sign.
       Here, the operation "/" would be "trunc_div", the fractional part is
       discarded. If "X - N * M" and "X" are in different signs, then trunc_div
       discards the fractional parts (of /N) in different directions.

            PR tree-optimization/108757

    gcc/ChangeLog:

            * match.pd ((X - N * M) / N): New pattern.
            ((X + N * M) / N): New pattern.
            ((X + C) div_rshift N): New pattern.

    gcc/testsuite/ChangeLog:

            * gcc.dg/pr108757-1.c: New test.
            * gcc.dg/pr108757-2.c: New test.
            * gcc.dg/pr108757.h: New test.
  • [Bug tree-optimization/108757] ... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to