diff mbox

[i386] Fix PR 81294, _subborrow_u64 argument order inconsistent with intrinsic reference

Message ID CAFULd4YGuKSFz8EtjjWFJ4PeXnjY8KacDtCJRQCNaxJfFy1weA@mail.gmail.com
State New
Headers show

Commit Message

Uros Bizjak July 4, 2017, 8:41 p.m. UTC
Hello!

Apparently, Intel changed operand order with the new intrinsic
reference release version. Attached patch updates gcc intrinsic
headers accordingly.

2017-07-04  Uros Bizjak  <ubizjak@gmail.com>

    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:

2017-07-04  Uros Bizjak  <ubizjak@gmail.com>

    PR target/81249
    * 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.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Committed to mainline SVN, willbe backported to release branches.

Uros.

Comments

Jakub Jelinek July 4, 2017, 8:51 p.m. UTC | #1
On Tue, Jul 04, 2017 at 10:41:26PM +0200, Uros Bizjak wrote:
> Hello!
> 
> Apparently, Intel changed operand order with the new intrinsic
> reference release version. Attached patch updates gcc intrinsic
> headers accordingly.
> 
> 2017-07-04  Uros Bizjak  <ubizjak@gmail.com>
> 
>     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:
> 
> 2017-07-04  Uros Bizjak  <ubizjak@gmail.com>
> 
>     PR target/81249
>     * 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.
> 
> Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.
> 
> Committed to mainline SVN, willbe backported to release branches.

When it goes into release branches, it needs changes.html changes
for each of those to make users aware of that.
7.2 will have rc after mid July, so if you want it in 7.2, it should be
committed before that.  5.5 + 5.x branch closing will be around that time
too.

	Jakub
diff mbox

Patch

Index: config/i386/adxintrin.h
===================================================================
--- config/i386/adxintrin.h	(revision 249971)
+++ config/i386/adxintrin.h	(working copy)
@@ -33,7 +33,7 @@ 
 _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 @@ 
 _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
Index: testsuite/gcc.target/i386/adx-addcarryx32-2.c
===================================================================
--- testsuite/gcc.target/i386/adx-addcarryx32-2.c	(revision 249971)
+++ testsuite/gcc.target/i386/adx-addcarryx32-2.c	(working copy)
@@ -44,9 +44,9 @@ 
   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)
Index: testsuite/gcc.target/i386/adx-addcarryx64-2.c
===================================================================
--- testsuite/gcc.target/i386/adx-addcarryx64-2.c	(revision 249971)
+++ testsuite/gcc.target/i386/adx-addcarryx64-2.c	(working copy)
@@ -44,9 +44,9 @@ 
   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)
Index: testsuite/gcc.target/i386/pr81294-1.c
===================================================================
--- testsuite/gcc.target/i386/pr81294-1.c	(nonexistent)
+++ testsuite/gcc.target/i386/pr81294-1.c	(working copy)
@@ -0,0 +1,29 @@ 
+/* PR target/81294 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#include <x86intrin.h>
+
+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;
+}
Index: testsuite/gcc.target/i386/pr81294-2.c
===================================================================
--- testsuite/gcc.target/i386/pr81294-2.c	(nonexistent)
+++ testsuite/gcc.target/i386/pr81294-2.c	(working copy)
@@ -0,0 +1,28 @@ 
+/* PR target/81294 */
+/* { dg-do run { target { ! ia32 } } } */
+/* { dg-options "-O2" } */
+
+#include <x86intrin.h>
+
+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;
+}