[Bug tree-optimization/109843] signbit comparisons -> copysign optimization

"cvs-commit at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109843

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

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

commit r17-2823-g1c8ca0108746d3a7452134f9d1c2e5d89857fed7
Author: Eikansh Gupta <[email protected]>
Date:   Wed Jun 17 09:58:16 2026 +0530

    MATCH: fold signbit comparison and conditional negate to copysign
[PR109843]

    Fold (signbit (x) cmp1 0) cmp (signbit (y) cmp2 0) ? y : -y
    to copysign (y, +-x).  The result keeps the magnitude of Y and takes its
    sign from X (or -X).  Emitted as IFN_COPYSIGN when the target supports it.

            PR tree-optimization/109843

    gcc/ChangeLog:

            * match.pd ((signbit (x) cmp 0) cmp (signbit (y) cmp 0) ? y : -y):
            New simplification to copysign (y, +-x).

    gcc/testsuite/ChangeLog:

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

    Signed-off-by: Eikansh Gupta <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.