Use Clang 3.6's __builtin_assume in Q_ASSUME
It's more efficient than the current implementation. Example: int f(int i) { Q_ASSUME(i < 8); return i < 8; } Before: cmpl $8, %edi setl %al movzbl %al, %eax retq After: movl $1, %eax retq Change-Id: I1a800c709d3543699131ffff13c1c50713a8da2c Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
parent
738e9b185c
commit
b584648df1
@ -173,7 +173,11 @@
|
||||
# else
|
||||
# define Q_CC_CLANG ((__clang_major__ * 100) + __clang_minor__)
|
||||
# endif
|
||||
# define Q_ASSUME_IMPL(expr) if (expr){} else __builtin_unreachable()
|
||||
# if __has_builtin(__builtin_assume)
|
||||
# define Q_ASSUME_IMPL(expr) __builtin_assume(expr)
|
||||
# else
|
||||
# define Q_ASSUME_IMPL(expr) if (expr){} else __builtin_unreachable()
|
||||
# endif
|
||||
# define Q_UNREACHABLE_IMPL() __builtin_unreachable()
|
||||
# if !defined(__has_extension)
|
||||
# /* Compatibility with older Clang versions */
|
||||
|
Loading…
x
Reference in New Issue
Block a user