[llvm-bugs] [Bug 45682] New: Failure to optimize some limit bounds patterns based on __builtin_assume

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Apr 26 15:57:14 PDT 2020


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

            Bug ID: 45682
           Summary: Failure to optimize some limit bounds patterns based
                    on __builtin_assume
           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

#include <limits.h>

#ifdef __clang__
#define assume __builtin_assume
#else

inline void assume(bool x)
{
    if (!x)
        __builtin_unreachable();
}

#endif

void g();

void f(int x, int y)
{
    assume(y > 0);
    x += y;
    if (x == -INT_MAX - 1)
      g();
}

`f` is optimized to doing nothing by gcc, clang does the check even though `y >
0` means the last condition is always false. Sample comparison here :
https://godbolt.org/z/x-cuqX

-- 
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/20200426/8d5fccb7/attachment.html>


More information about the llvm-bugs mailing list