]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Sync intprops.h from Gnulib
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 5 Aug 2020 05:58:58 +0000 (22:58 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 5 Aug 2020 05:58:58 +0000 (22:58 -0700)
* include/intprops.h: Sync from Gnulib.  This improves
performance of INT_MULTIPLY_WRAPV on recent GCC, which affects
glibc only in the support library.

include/intprops.h

index 0c379a8c5b2e88473d0ebdc344acbe984d29b9db..6de65b067d414437be45bc878d03043a253f60d4 100644 (file)
    _GL_INT_OP_WRAPV (a, b, r, -, _GL_INT_SUBTRACT_RANGE_OVERFLOW)
 #endif
 #if _GL_HAS_BUILTIN_MUL_OVERFLOW
-/* Work around GCC bug 91450.  */
-# define INT_MULTIPLY_WRAPV(a, b, r) \
-   ((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && EXPR_SIGNED (a) && EXPR_SIGNED (b) \
-     && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \
-    ? ((void) __builtin_mul_overflow (a, b, r), 1) \
-    : __builtin_mul_overflow (a, b, r))
+# if (9 < __GNUC__ + (3 <= __GNUC_MINOR__) \
+      || (__GNUC__ == 8 && 4 <= __GNUC_MINOR__))
+#  define INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r)
+# else
+   /* Work around GCC bug 91450.  */
+#  define INT_MULTIPLY_WRAPV(a, b, r) \
+    ((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && EXPR_SIGNED (a) && EXPR_SIGNED (b) \
+      && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \
+     ? ((void) __builtin_mul_overflow (a, b, r), 1) \
+     : __builtin_mul_overflow (a, b, r))
+# endif
 #else
 # define INT_MULTIPLY_WRAPV(a, b, r) \
    _GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW)