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

--- Comment #36 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jeff Law <l...@gcc.gnu.org>:

https://gcc.gnu.org/g:e4c1b3d45a33cfb9d76be11c362f81aa77e29882

commit r15-5836-ge4c1b3d45a33cfb9d76be11c362f81aa77e29882
Author: Alexey Merzlyakov <alexey.merzlya...@samsung.com>
Date:   Sat Nov 30 19:01:28 2024 -0700

    [PATCH v3] zero_extend(not) -> xor optimization [PR112398]

    This patch adds optimization of the following patterns:

      (zero_extend:M (subreg:N (not:O==M (X:Q==M)))) ->
      (xor:M (zero_extend:M (subreg:N (X:M)), mask))
      ... where the mask is GET_MODE_MASK (N).

    For the cases when X:M doesn't have any non-zero bits outside of mode N,
    (zero_extend:M (subreg:N (X:M)) could be simplified to just (X:M)
    and whole optimization will be:

      (zero_extend:M (subreg:N (not:M (X:M)))) ->
      (xor:M (X:M, mask))

    Patch targets to handle code patterns like:
      not   a0,a0
      andi  a0,a0,0xff
    to be optimized to:
      xori  a0,a0,255

            PR rtl-optimization/112398
            PR rtl-optimization/117476

    gcc/ChangeLog:

            * simplify-rtx.cc (simplify_context::simplify_unary_operation_1):
            Simplify ZERO_EXTEND (SUBREG (NOT X)) to XOR (X,
GET_MODE_MASK(SUBREG))
            when X doesn't have any non-zero bits outside of SUBREG mode.

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/pr112398.c: New test.
            * gcc.dg/torture/pr117476-1.c: New test. From Zhendong Su.
            * gcc.dg/torture/pr117476-2.c: New test. From Zdenek Sojka.

Reply via email to