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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <[email protected]>:

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

commit r17-542-gab6c415e13ca87e3e4c7a24ccd9bf83e23ef30ee
Author: Shivam Gupta <[email protected]>
Date:   Tue May 12 23:17:05 2026 +0530

    match.pd: Simplify ((~x) & y) ^ (x | y)

    This adds the simplification of:
      _1 = ~x_2(D);
      t1_4 = _1 & y_3(D);
      t2_5 = x_2(D) | y_3(D);
      _6 = t1_4 ^ t2_5;
      return _6;

    to:
      return x_1(D);

    also for ((~x) | y) ^ (x & y) version
      _1 = ~x_2(D);
      t1_4 = _1 | y_3(D);
      t2_5 = x_2(D) & y_3(D);
      _6 = t1_4 ^ t2_5;
      return _6;
    to:
       int _1;
       _1 = ~x_2(D);
       return _1;

    Bootstrapped and tested on aarch64-linux-gnu with
    RUNTESTFLAGS="tree-ssa.exp".

    changes since v1:
    * v3: Change sf2/sg2 to sf/sg in test case
    * v2:
    - Update testcase to exercise GIMPLE folding
    - Add additional type coverage
    - Add vector and _Bool coverage
    - Move code above in the file

            PR tree-optimization/112095

    gcc/ChangeLog:

            * match.pd: Simplify ((~x) & y) ^ (x | y)
            to x and ((~x) | y) ^ (x & y) to ~x.

    gcc/testsuite/ChangeLog:

            * gcc.dg/tree-ssa/pr112095.c: New test.

    Signed-off-by: Shivam Gupta <[email protected]>

Reply via email to