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

            Bug ID: 115306
           Summary: (X + 1) > Y ? -X : 1 pattern does not handle X=~X nor
                    X = -X;
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

The new pattern:
/* (1 - X) > Y ? X : 1 simplifies to (-X) >= Y ? X : 1 when
   X is unsigned for the same logic as above, just replace X with -X.  */
(simplify
 (cond (gt (minus integer_onep @0) @1) @0 integer_onep@2)
 (if (TYPE_UNSIGNED (type))
  (cond (ge (negate @0) @1) @0 @2)))

Reply via email to