+2014-09-03 Ilya Tocar <ilya.tocar@intel.com>
+
+ * config/i386/adxintrin.h (_subborrow_u32): New.
+ (_addcarry_u32): Ditto.
+ (_subborrow_u64): Ditto.
+ (_addcarry_u64): Ditto.
+ * config/i386/i386.c (ix86_builtins): Add IX86_BUILTIN_SBB32,
+ IX86_BUILTIN_SBB64.
+ (ix86_init_mmx_sse_builtins): Handle __builtin_ia32_sbb_u32,
+ __builtin_ia32_sbb_u64
+
2014-09-03 Chung-Ju Wu <jasonwucj@gmail.com>
* config/nds32/nds32.c (nds32_function_arg): Define and rename some
#ifndef _ADXINTRIN_H_INCLUDED
#define _ADXINTRIN_H_INCLUDED
+extern __inline unsigned char
+__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);
+}
+
+extern __inline unsigned char
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_addcarry_u32 (unsigned char __CF, unsigned int __X,
+ unsigned int __Y, unsigned int *__P)
+{
+ return __builtin_ia32_addcarryx_u32 (__CF, __X, __Y, __P);
+}
+
extern __inline unsigned char
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_addcarryx_u32 (unsigned char __CF, unsigned int __X,
}
#ifdef __x86_64__
+extern __inline unsigned char
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_subborrow_u64 (unsigned char __CF, unsigned long __X,
+ unsigned long __Y, unsigned long long *__P)
+{
+ return __builtin_ia32_sbb_u64 (__CF, __Y, __X, __P);
+}
+
+extern __inline unsigned char
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_addcarry_u64 (unsigned char __CF, unsigned long __X,
+ unsigned long __Y, unsigned long long *__P)
+{
+ return __builtin_ia32_addcarryx_u64 (__CF, __X, __Y, __P);
+}
+
extern __inline unsigned char
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_addcarryx_u64 (unsigned char __CF, unsigned long __X,
IX86_BUILTIN_ADDCARRYX32,
IX86_BUILTIN_ADDCARRYX64,
+ /* SBB instructions. */
+ IX86_BUILTIN_SBB32,
+ IX86_BUILTIN_SBB64,
+
/* FSGSBASE instructions. */
IX86_BUILTIN_RDFSBASE32,
IX86_BUILTIN_RDFSBASE64,
UCHAR_FTYPE_UCHAR_ULONGLONG_ULONGLONG_PULONGLONG,
IX86_BUILTIN_ADDCARRYX64);
+ /* SBB */
+ def_builtin (0, "__builtin_ia32_sbb_u32",
+ UCHAR_FTYPE_UCHAR_UINT_UINT_PUNSIGNED, IX86_BUILTIN_SBB32);
+ def_builtin (OPTION_MASK_ISA_64BIT,
+ "__builtin_ia32_sbb_u64",
+ UCHAR_FTYPE_UCHAR_ULONGLONG_ULONGLONG_PULONGLONG,
+ IX86_BUILTIN_SBB64);
+
/* Read/write FLAGS. */
def_builtin (~OPTION_MASK_ISA_64BIT, "__builtin_ia32_readeflags_u32",
UNSIGNED_FTYPE_VOID, IX86_BUILTIN_READ_FLAGS);
emit_insn (gen_zero_extendqisi2 (target, op2));
return target;
+ case IX86_BUILTIN_SBB32:
+ icode = CODE_FOR_subsi3_carry;
+ mode0 = SImode;
+ goto addcarryx;
+
+ case IX86_BUILTIN_SBB64:
+ icode = CODE_FOR_subdi3_carry;
+ mode0 = DImode;
+ goto addcarryx;
+
case IX86_BUILTIN_ADDCARRYX32:
icode = TARGET_ADX ? CODE_FOR_adcxsi3 : CODE_FOR_addsi3_carry;
mode0 = SImode;
+2014-09-03 Ilya Tocar <ilya.tocar@intel.com>
+
+ * gcc.target/i386/adx-addcarryx32-1.c: Test addcarry, subborrow.
+ * gcc.target/i386/adx-addcarryx32-2.c: Ditto.
+ * gcc.target/i386/adx-addcarryx32-3.c: Ditto.
+ * gcc.target/i386/adx-addcarryx64-1.c: Ditto.
+ * gcc.target/i386/adx-addcarryx64-2.c: Ditto.
+ * gcc.target/i386/adx-addcarryx64-3.c: Ditto.
+
2014-09-03 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
PR target/61078
/* { dg-do compile } */
/* { dg-options "-madx -O2" } */
-/* { dg-final { scan-assembler "adcx" } } */
+/* { dg-final { scan-assembler-times "adcx" 2 } } */
+/* { dg-final { scan-assembler-times "sbbl" 1 } } */
#include <x86intrin.h>
adx_test (void)
{
c = _addcarryx_u32 (c, x, y, sum);
+ c = _addcarry_u32 (c, x, y, sum);
+ c = _subborrow_u32 (c, x, y, sum);
}
c = _addcarryx_u32 (c, x, y, &x);
/* X = 0xFFFFFFFE, Y = 0xFFFFFFFF, C = 1. */
+ if (x != sum_ref)
+ abort ();
+
+ c = 0;
+ x = y = 0xFFFFFFFF;
+ sum_ref = 0xFFFFFFFE;
+
+ /* X = 0xFFFFFFFF, Y = 0xFFFFFFFF, C = 0. */
+ c = _addcarry_u32 (c, x, y, &x);
+ /* X = 0xFFFFFFFE, Y = 0xFFFFFFFF, C = 1. */
+ c = _addcarry_u32 (c, x, y, &x);
+ /* X = 0xFFFFFFFE, Y = 0xFFFFFFFF, C = 1. */
+
+ if (x != sum_ref)
+ abort ();
+
+ c = 0;
+ x = 1;
+ y = 0;
+ sum_ref = 0x0;
+
+ /* X = 0x00000001, Y = 0x00000000, C = 0. */
+ c = _subborrow_u32 (c, x, y, &x);
+ /* X = 0xFFFFFFFF, Y = 0x00000000, C = 1. */
+ c = _subborrow_u32 (c, x, y, &x);
+ /* X = 0xFFFFFFFF, Y = 0xFFFFFFFF, C = 1. */
+
if (x != sum_ref)
abort ();
}
/* { dg-do compile } */
/* { dg-options "-mno-adx -O2" } */
-/* { dg-final { scan-assembler "adcl" } } */
+/* { dg-final { scan-assembler-times "adcl" 2 } } */
+/* { dg-final { scan-assembler-times "sbbl" 1 } } */
#include <x86intrin.h>
adx_test (void)
{
c = _addcarryx_u32 (c, x, y, sum);
+ c = _addcarry_u32 (c, x, y, sum);
+ c = _subborrow_u32 (c, x, y, sum);
}
/* { dg-do compile { target { ! ia32 } } } */
/* { dg-options "-madx -O2" } */
-/* { dg-final { scan-assembler "adcx" } } */
+/* { dg-final { scan-assembler-times "adcx" 2 } } */
+/* { dg-final { scan-assembler-times "sbbq" 1 } } */
#include <x86intrin.h>
adx_test (void)
{
c = _addcarryx_u64 (c, x, y, sum);
+ c = _addcarry_u64 (c, x, y, sum);
+ c = _subborrow_u64 (c, x, y, sum);
}
c = _addcarryx_u64 (c, x, y, &x);
/* X = 0xFFFFFFFFFFFFFFFE, Y = 0xFFFFFFFFFFFFFFFF, C = 1. */
+ if (x != sum_ref)
+ abort ();
+
+ c = 0;
+ x = y = 0xFFFFFFFFFFFFFFFFLL;
+ sum_ref = 0xFFFFFFFFFFFFFFFELL;
+
+ /* X = 0xFFFFFFFFFFFFFFFF, Y = 0xFFFFFFFFFFFFFFFF, C = 0. */
+ c = _addcarry_u64 (c, x, y, &x);
+ /* X = 0xFFFFFFFFFFFFFFFE, Y = 0xFFFFFFFFFFFFFFFF, C = 1. */
+ c = _addcarry_u64 (c, x, y, &x);
+ /* X = 0xFFFFFFFFFFFFFFFE, Y = 0xFFFFFFFFFFFFFFFF, C = 1. */
+
+ if (x != sum_ref)
+ abort ();
+
+ c = 0;
+ x = 1LL;
+ y = 0LL;
+ sum_ref = 0x0LL;
+
+ /* X = 0x0000000000000001, Y = 0x0000000000000000, C = 0. */
+ c = _subborrow_u64 (c, x, y, &x);
+ /* X = 0xFFFFFFFFFFFFFFFF, Y = 0x0000000000000000, C = 1. */
+ c = _subborrow_u64 (c, x, y, &x);
+ /* X = 0x0000000000000000, Y = 0x0000000000000000, C = 1. */
+
if (x != sum_ref)
abort ();
}
/* { dg-do compile { target { ! ia32 } } } */
/* { dg-options "-mno-adx -O2" } */
-/* { dg-final { scan-assembler "adcq" } } */
+/* { dg-final { scan-assembler-times "adcq" 2 } } */
+/* { dg-final { scan-assembler-times "sbbq" 1 } } */
#include <x86intrin.h>
adx_test (void)
{
c = _addcarryx_u64 (c, x, y, sum);
+ c = _addcarry_u64 (c, x, y, sum);
+ c = _subborrow_u64 (c, x, y, sum);
}