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

            Bug ID: 105777
           Summary: Failure to optimize __builtin_mul_overflow with
                    constant operand to add+cmp check
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

int f17(unsigned x)
{
    int z;
    return __builtin_mul_overflow((int)x, 35, &z);
}

This can be optimized to `return (x + 0xFC57C57C) < 0xF8AF8AF9;` (and I'd
assume the same pattern with other constants than 35 should be optimizable in
the same way). LLVM does this transformation, but GCC does not.

Reply via email to