https://bugs.llvm.org/show_bug.cgi?id=45688

            Bug ID: 45688
           Summary: Missed optimization on comparison after knowing
                    __builtin_uadd_overflow didn't overflow
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

bool f(unsigned a, unsigned b)
{
    unsigned result;
    bool overflowed = __builtin_uadd_overflow(a, b, &result);
    __builtin_assume(!overflowed);

    return result >= b;
}

This can be optimized to `return 1;`. This transformation is done by GCC, but
not by LLVM.

Comparison here : https://godbolt.org/z/i44m2a

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to