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

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

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

commit r17-4663-gbddea69ee406a0f68aed8f42ea7efba2d8b5883c
Author: Aldy Hernandez <[email protected]>
Date:   Sat Aug 29 20:16:11 2026 +0000

    range-ops: derive operand equality from a zero MINUS_EXPR

    A conditional such as:

      d_5 = a_3 - b_4;
      if (d_5 == 0)

    implies a_3 == b_4 on the true edge regardless of overflow behavior,
    but no relation was recorded because operator_minus lacks
    op1_op2_relation and register_outgoing_edges only derives relations
    from boolean exports.  Add the former and relax the latter.

    match.pd already folds this:

      /* Transform comparisons of the form X - Y CMP 0 to X CMP Y.  */
      (cmp (sub@2 @0 @1) integer_zerop)
       (if (single_use (@2)) (cmp @0 @1))

    but only for a single-use difference.

    Measured with perf over a corpus of .ii files from a stage1 bootstrap
    compile time is +0.13% overall.  VRP is +0.8%, DOM +1.7% and the
    threader +3.4%.  The cost is register_outgoing_edges itself which is
    +36%.

    Tested on ppc64le Linux.

            PR tree-optimization/127485

    gcc/ChangeLog:

            * range-op-mixed.h (class operator_minus): Add op1_op2_relation.
            * range-op.cc (operator_minus::op1_op2_relation): New.
            * gimple-range-fold.cc (fur_source::register_outgoing_edges):
            Derive relations from any integral export, not just booleans.

    gcc/testsuite/ChangeLog:

            * gcc.dg/tree-ssa/vrp-minus-relation-1.c: New test.

Reply via email to