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

--- Comment #14 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Roger Sayle <sa...@gcc.gnu.org>:

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

commit r12-3660-ge9e46864cd0695d2dcec5c513f249b1e1ab0056f
Author: Roger Sayle <ro...@nextmovesoftware.com>
Date:   Sun Sep 19 09:07:01 2021 +0100

    PR middle-end/88173: More constant folding of NaN comparisons.

    This patch tackles PR middle-end/88173 where the order of operands in
    a comparison affects constant folding.  As diagnosed by Jason Merrill,
    "match.pd handles these comparisons very differently".  The history is
    that the middle end, typically canonicalizes comparisons to place
    constants on the right, but when a comparison contains two constants
    we need to check/transform both constants, i.e. on both the left and the
    right.  Hence the added lines below duplicate for @0 the same transform
    applied a few lines above for @1.

    Whilst preparing the testcase, I noticed that this transformation is
    incorrectly disabled with -fsignaling-nans even when both operands are
    known not be be signaling NaNs, so I've corrected that and added a
    second test case.  Unfortunately, c-c++-common/pr57371-4.c then starts
    failing, as it doesn't distinguish QNaNs (which are quiet) from SNaNs
    (which signal), so this patch includes a minor tweak to the expected
    behaviour for QNaNs in that existing test.

    2021-09-19  Roger Sayle <ro...@nextmovesoftware.com>

    gcc/ChangeLog
            PR middle-end/88173
            * match.pd (cmp @0 REAL_CST@1): When @0 is also REAL_CST, apply
            the same transformations as to @1.  For comparisons against NaN,
            don't check HONOR_SNANS but confirm that neither operand is a
            signaling NaN.

    gcc/testsuite/ChangeLog
            PR middle-end/88173
            * c-c++-common/pr57371-4.c: Tweak/correct test case for QNaNs.
            * g++.dg/pr88173-1.C: New test case.
            * g++.dg/pr88173-2.C: New test case.

Reply via email to