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

            Bug ID: 128292
           Summary: [14/15/16 Regression] wrong code at -O2: fabs()
                    ignored on negative value in tree-vrp
           Product: gcc
           Version: 16.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: christian.klein at advantest dot com
  Target Milestone: ---

Created attachment 66037
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=66037&action=edit
Reproducer

The attached reproducer computes the wrong result with 14/15/16 and -O2 (or -O1
-ftree-vrp).
GCC 13 handles it correctly.

Looking at the assembler output, it seems to me that the value range
propagation algorithm decides that the `fabs()` calls are unnecessary for some
reason.
So the calculated eps is negative, leading to the inequality check never
returning true.

It also seems that GCC 16 is more aggressive with applying this (broken)
optimisation, as our somewhat more complicated double code only fails with GCC
16, while the simplified reproducer fails on GCC 13 and 14, too.

On trunk this problem no longer exists. A bisect shows the following commit
"solved" the problem:

commit f8dce99ad72e98b72df2b1a0fc126409fa7d3c1c
Author: Richard Sandiford <[email protected]>
Date:   Tue Jun 2 20:50:29 2026 +0100

    backprop: Create new SSA names


To me it looks like this commit (part of a series) is not a deliberate fix, but
rather a rewrite of the code in question that fixed the bug as a side effect.

Reply via email to