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

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

https://gcc.gnu.org/g:7659926b80deaf0523d9ccee51446b4187f978cb

commit r17-1582-g7659926b80deaf0523d9ccee51446b4187f978cb
Author: Avinash Jayakar <[email protected]>
Date:   Wed Jun 10 12:46:50 2026 +0530

    match.pd: Recognize integer spaceship operator patterns

    There are certain patterns that are not recognized by the method
    optimize_spaceship. For example,
      a == b ? 0 : (a > b) : 1 : -1;
    is rightly recognized as spaceship operator. But
      a <= b ? -(a < b) : 1 or
      a >= b ? (a > b) : -1
    is not being currently recognized.

    This patch recognizes such patterns and chooses to emit the spaceship
    optab if target supports it, which improves code-generation for such
    targets.

    2026-06-16  Avinash Jayakar  <[email protected]>

    gcc/ChangeLog:
            PR tree-optimization/59429
            * match.pd: New match patterns to recognize spaceship variants.
            * tree-ssa-math-opts.cc (gimple_spaceship): Match function
declaration.
            (match_spaceship): New function to recognize spaceship given phi
node.
            (math_opts_dom_walker::after_dom_children): Add match_spaceship
check.

    gcc/testsuite/ChangeLog:
            PR tree-optimization/59429
            * lib/target-supports.exp (check_effective_target_spaceship): Add
new
            proc for spaceship optab. x86, aarch64 and s390 included.
            * gcc.dg/spaceship_int_variants.c: New test.
            * gcc.dg/spaceship_uint_variants.c: New test.
            * gcc.dg/spaceship_mixed_variants.c: New test.

Reply via email to