[llvm-bugs] [Bug 49057] New: Failure to optimize out redundant overflow check

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Feb 5 07:12:27 PST 2021


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

            Bug ID: 49057
           Summary: Failure to optimize out redundant overflow check
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: gabravier at gmail.com
                CC: llvm-bugs at lists.llvm.org

unsigned foo(unsigned a, unsigned b)
{
    unsigned sum = a + b;
    if (sum < a)
        abort();
    if (sum < b)
        abort();
    return sum;
}

The second `if` condition can be optimized out. This transformation is done by
GCC, but not by LLVM.

Godbolt comparison: https://godbolt.org/z/KeGWx8
alive2 check: https://alive2.llvm.org/ce/z/5hk_x7

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210205/6eb870a3/attachment.html>


More information about the llvm-bugs mailing list