[llvm-bugs] [Bug 48516] New: Failure to optimize loop that does nothing and ends when result is used in comparison that is optimized out

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Dec 15 05:58:06 PST 2020


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

            Bug ID: 48516
           Summary: Failure to optimize loop that does nothing and ends
                    when result is used in comparison that is optimized
                    out
           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

void f(int *x, int *y)
{
    long res = 0;

    for (int i = 0; i < 100; i++)
        res += x[i] * y[i];

    if (res != 0)
        __builtin_abort();
    __builtin_unreachable();
}

This entire function can be optimized into `abort()`. This transformation is
done by GCC, but not by LLVM.

See also comparison here : https://godbolt.org/z/anzYMa

-- 
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/20201215/3e015da3/attachment.html>


More information about the llvm-bugs mailing list