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: [email protected]
          Reporter: [email protected]
                CC: [email protected]

#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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to