From 1fcfac88dec24a5ae005a82b1aa85e0e4291a81e Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Tue, 4 Jul 2017 22:46:38 +0200 Subject: [PATCH] re PR target/81294 (_subborrow_u64 argument order inconsistent with intrinsic reference, icc) PR target/81294 * config/i386/adxintrin.h (_subborrow_u32): Swap _X and _Y arguments in the call to __builtin_ia32_sbb_u32. (_subborrow_u64): Swap _X and _Y arguments in the call to __builtin_ia32_sbb_u64. testsuite/ChangeLog: PR target/81294 * gcc.target/i386/adx-addcarryx32-2.c (adx_test): Swap x and y arguments in the call to _subborrow_u32. * gcc.target/i386/adx-addcarryx64-2.c (adx_test): Swap x and y arguments in the call to _subborrow_u64. * gcc.target/i386/pr81294-1.c: New test. * gcc.target/i386/pr81294-2.c: Ditto. From-SVN: r249976 --- gcc/ChangeLog | 8 +++++ gcc/config/i386/adxintrin.h | 4 +-- gcc/testsuite/ChangeLog | 10 +++++++ .../gcc.target/i386/adx-addcarryx32-2.c | 4 +-- .../gcc.target/i386/adx-addcarryx64-2.c | 4 +-- gcc/testsuite/gcc.target/i386/pr81294-1.c | 29 +++++++++++++++++++ gcc/testsuite/gcc.target/i386/pr81294-2.c | 28 ++++++++++++++++++ 7 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr81294-1.c create mode 100644 gcc/testsuite/gcc.target/i386/pr81294-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d57f764b42d..e09edc970f1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2017-07-04 Uros Bizjak + + PR target/81294 + * config/i386/adxintrin.h (_subborrow_u32): Swap _X and _Y + arguments in the call to __builtin_ia32_sbb_u32. + (_subborrow_u64): Swap _X and _Y arguments in the call to + __builtin_ia32_sbb_u64. + 2017-07-04 Jakub Jelinek PR debug/81278 diff --git a/gcc/config/i386/adxintrin.h b/gcc/config/i386/adxintrin.h index 9c4152b9f36..7acdaf4ab6f 100644 --- a/gcc/config/i386/adxintrin.h +++ b/gcc/config/i386/adxintrin.h @@ -33,7 +33,7 @@ __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _subborrow_u32 (unsigned char __CF, unsigned int __X, unsigned int __Y, unsigned int *__P) { - return __builtin_ia32_sbb_u32 (__CF, __Y, __X, __P); + return __builtin_ia32_sbb_u32 (__CF, __X, __Y, __P); } extern __inline unsigned char @@ -58,7 +58,7 @@ __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _subborrow_u64 (unsigned char __CF, unsigned long long __X, unsigned long long __Y, unsigned long long *__P) { - return __builtin_ia32_sbb_u64 (__CF, __Y, __X, __P); + return __builtin_ia32_sbb_u64 (__CF, __X, __Y, __P); } extern __inline unsigned char diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f1fbe61d131..18ec2147b16 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2017-07-04 Uros Bizjak + + PR target/81294 + * gcc.target/i386/adx-addcarryx32-2.c (adx_test): Swap + x and y arguments in the call to _subborrow_u32. + * gcc.target/i386/adx-addcarryx64-2.c (adx_test): Swap + x and y arguments in the call to _subborrow_u64. + * gcc.target/i386/pr81294-1.c: New test. + * gcc.target/i386/pr81294-2.c: Ditto. + 2017-07-04 Kyrylo Tkachov * gcc.target/aarch64/simd/vminmaxnm_1.c: Fix strict aliasing issues. diff --git a/gcc/testsuite/gcc.target/i386/adx-addcarryx32-2.c b/gcc/testsuite/gcc.target/i386/adx-addcarryx32-2.c index b1da555bc31..ddee754c962 100644 --- a/gcc/testsuite/gcc.target/i386/adx-addcarryx32-2.c +++ b/gcc/testsuite/gcc.target/i386/adx-addcarryx32-2.c @@ -44,9 +44,9 @@ adx_test (void) sum_ref = 0x0; /* X = 0x00000001, Y = 0x00000000, C = 0. */ - c = _subborrow_u32 (c, x, y, &x); + c = _subborrow_u32 (c, y, x, &x); /* X = 0xFFFFFFFF, Y = 0x00000000, C = 1. */ - c = _subborrow_u32 (c, x, y, &x); + c = _subborrow_u32 (c, y, x, &x); /* X = 0xFFFFFFFF, Y = 0xFFFFFFFF, C = 1. */ if (x != sum_ref) diff --git a/gcc/testsuite/gcc.target/i386/adx-addcarryx64-2.c b/gcc/testsuite/gcc.target/i386/adx-addcarryx64-2.c index b326291bb35..287e263a9dd 100644 --- a/gcc/testsuite/gcc.target/i386/adx-addcarryx64-2.c +++ b/gcc/testsuite/gcc.target/i386/adx-addcarryx64-2.c @@ -44,9 +44,9 @@ adx_test (void) sum_ref = 0x0LL; /* X = 0x0000000000000001, Y = 0x0000000000000000, C = 0. */ - c = _subborrow_u64 (c, x, y, &x); + c = _subborrow_u64 (c, y, x, &x); /* X = 0xFFFFFFFFFFFFFFFF, Y = 0x0000000000000000, C = 1. */ - c = _subborrow_u64 (c, x, y, &x); + c = _subborrow_u64 (c, y, x, &x); /* X = 0x0000000000000000, Y = 0x0000000000000000, C = 1. */ if (x != sum_ref) diff --git a/gcc/testsuite/gcc.target/i386/pr81294-1.c b/gcc/testsuite/gcc.target/i386/pr81294-1.c new file mode 100644 index 00000000000..6a15ed0a410 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr81294-1.c @@ -0,0 +1,29 @@ +/* PR target/81294 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include + +int +main () +{ + volatile unsigned char c; + unsigned int x; + volatile unsigned int y, sum_ref; + + c = 0; + x = 1; + y = 0; + sum_ref = 0x0; + + /* X = 0x00000001, Y = 0x00000000, C = 0. */ + c = _subborrow_u32 (c, y, x, &x); + /* X = 0xFFFFFFFF, Y = 0x00000000, C = 1. */ + c = _subborrow_u32 (c, y, x, &x); + /* X = 0xFFFFFFFF, Y = 0xFFFFFFFF, C = 1. */ + + if (x != sum_ref) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/pr81294-2.c b/gcc/testsuite/gcc.target/i386/pr81294-2.c new file mode 100644 index 00000000000..3e3bdb44139 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr81294-2.c @@ -0,0 +1,28 @@ +/* PR target/81294 */ +/* { dg-do run { target { ! ia32 } } } */ +/* { dg-options "-O2" } */ + +#include + +int main () +{ + volatile unsigned char c; + unsigned long long x; + volatile unsigned long long y, sum_ref; + + c = 0; + x = 1LL; + y = 0LL; + sum_ref = 0x0LL; + + /* X = 0x0000000000000001, Y = 0x0000000000000000, C = 0. */ + c = _subborrow_u64 (c, y, x, &x); + /* X = 0xFFFFFFFFFFFFFFFF, Y = 0x0000000000000000, C = 1. */ + c = _subborrow_u64 (c, y, x, &x); + /* X = 0x0000000000000000, Y = 0x0000000000000000, C = 1. */ + + if (x != sum_ref) + __builtin_abort (); + + return 0; +} -- 2.30.2