Re: [PATCH] PR middle-end/126775: ICE optimizing (T)0.0 - x with -ffinite-math-only

Richard Biener <[email protected]>
Newsgroups gmane.comp.gcc.patches
Message-ID <CAFiYyc2VG7q_Wkn2-dJhdqhHZM2JA3M7ox4baQ-ZSvk+-maz4w@mail.gmail.com>
On Wed, Aug 19, 2026 at 10:22 PM Roger Sayle <[email protected]> wrote:
>
>
> This patch fixes PR middle-end/126775, an ICE caused by my recent change
> to match.pd around tweaking the conditions under which 0.0 - x can
> safely be transformed into -x.  Unfortunately, that change assumed
> that real_zerop@0 implies that TREE_CODE(@0) == REAL_CST.  Alas things
> aren't that simple, so this fix introduces a new real_negzerop predicate
> that in addition to REAL_CST also handles VECTOR_CST and COMPLEX_CST,
> and most importantly fails gracefully on TREE_CODEs that it isn't
> expecting.
>
> This patch has been tested on x86_64-pc-linux-gnu with make bootstrap
> and make -k check, both with and without --target_board=unix{-m32}
> with no new failures.  Ok for mainline?

OK.

Thanks,
Richard.

>
> 2026-08-19  Roger Sayle  <[email protected]>
>
> gcc/ChangeLog
>         PR middle-end/126775
>         * match.pd (0.0 - x -> -x): Use new real_negzerop function.
>         * tree.cc (real_negzerop): New predicate function to test if
>         a tree expression is -0.0 or equivalent (like real_zerop).
>         * tree.h (real_negzerop): Prototype here.
>
> gcc/testsuite/ChangeLog
>         PR middle-end/126775
>         * gcc.dg/pr126775.c: New test case.
>
>
> Thanks again, and apologies for any inconvenice.
> Roger
> --
>
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.