From 9c6fb3ba59e1692160666e6ef21e654e6366af01 Mon Sep 17 00:00:00 2001 From: Ilya Tocar Date: Wed, 3 Sep 2014 09:24:34 +0000 Subject: [PATCH] adxintrin.h (_subborrow_u32): New. gcc/ 2014-09-02 Ilya Tocar * 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 testsuite/ 2014-09-02 Ilya Tocar * 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. From-SVN: r214860 --- gcc/ChangeLog | 11 +++++++ gcc/config/i386/adxintrin.h | 32 +++++++++++++++++++ gcc/config/i386/i386.c | 22 +++++++++++++ gcc/testsuite/ChangeLog | 9 ++++++ .../gcc.target/i386/adx-addcarryx32-1.c | 5 ++- .../gcc.target/i386/adx-addcarryx32-2.c | 27 ++++++++++++++++ .../gcc.target/i386/adx-addcarryx32-3.c | 5 ++- .../gcc.target/i386/adx-addcarryx64-1.c | 5 ++- .../gcc.target/i386/adx-addcarryx64-2.c | 27 ++++++++++++++++ .../gcc.target/i386/adx-addcarryx64-3.c | 5 ++- 10 files changed, 144 insertions(+), 4 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index db52c616546..d620cb28939 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2014-09-03 Ilya Tocar + + * 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 * config/nds32/nds32.c (nds32_function_arg): Define and rename some diff --git a/gcc/config/i386/adxintrin.h b/gcc/config/i386/adxintrin.h index 611890044c4..8f2c01a121b 100644 --- a/gcc/config/i386/adxintrin.h +++ b/gcc/config/i386/adxintrin.h @@ -28,6 +28,22 @@ #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, @@ -37,6 +53,22 @@ _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, diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 61b33782725..1ca4890c02d 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -28789,6 +28789,10 @@ enum ix86_builtins IX86_BUILTIN_ADDCARRYX32, IX86_BUILTIN_ADDCARRYX64, + /* SBB instructions. */ + IX86_BUILTIN_SBB32, + IX86_BUILTIN_SBB64, + /* FSGSBASE instructions. */ IX86_BUILTIN_RDFSBASE32, IX86_BUILTIN_RDFSBASE64, @@ -31224,6 +31228,14 @@ ix86_init_mmx_sse_builtins (void) 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); @@ -35628,6 +35640,16 @@ rdseed_step: 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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 63105ca7b8e..4065e49dc9a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2014-09-03 Ilya Tocar + + * 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 PR target/61078 diff --git a/gcc/testsuite/gcc.target/i386/adx-addcarryx32-1.c b/gcc/testsuite/gcc.target/i386/adx-addcarryx32-1.c index daf5779b196..9fff611b6c0 100644 --- a/gcc/testsuite/gcc.target/i386/adx-addcarryx32-1.c +++ b/gcc/testsuite/gcc.target/i386/adx-addcarryx32-1.c @@ -1,6 +1,7 @@ /* { 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 @@ -12,4 +13,6 @@ void extern adx_test (void) { c = _addcarryx_u32 (c, x, y, sum); + c = _addcarry_u32 (c, x, y, sum); + c = _subborrow_u32 (c, x, y, sum); } diff --git a/gcc/testsuite/gcc.target/i386/adx-addcarryx32-2.c b/gcc/testsuite/gcc.target/i386/adx-addcarryx32-2.c index d38d7ee784f..b1da555bc31 100644 --- a/gcc/testsuite/gcc.target/i386/adx-addcarryx32-2.c +++ b/gcc/testsuite/gcc.target/i386/adx-addcarryx32-2.c @@ -22,6 +22,33 @@ adx_test (void) 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 (); } diff --git a/gcc/testsuite/gcc.target/i386/adx-addcarryx32-3.c b/gcc/testsuite/gcc.target/i386/adx-addcarryx32-3.c index 0ed33a9503e..d804867a77e 100644 --- a/gcc/testsuite/gcc.target/i386/adx-addcarryx32-3.c +++ b/gcc/testsuite/gcc.target/i386/adx-addcarryx32-3.c @@ -1,6 +1,7 @@ /* { 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 @@ -12,4 +13,6 @@ void extern adx_test (void) { c = _addcarryx_u32 (c, x, y, sum); + c = _addcarry_u32 (c, x, y, sum); + c = _subborrow_u32 (c, x, y, sum); } diff --git a/gcc/testsuite/gcc.target/i386/adx-addcarryx64-1.c b/gcc/testsuite/gcc.target/i386/adx-addcarryx64-1.c index 45beca851f2..3608dea79b9 100644 --- a/gcc/testsuite/gcc.target/i386/adx-addcarryx64-1.c +++ b/gcc/testsuite/gcc.target/i386/adx-addcarryx64-1.c @@ -1,6 +1,7 @@ /* { 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 @@ -12,4 +13,6 @@ void extern adx_test (void) { c = _addcarryx_u64 (c, x, y, sum); + c = _addcarry_u64 (c, x, y, sum); + c = _subborrow_u64 (c, x, y, sum); } diff --git a/gcc/testsuite/gcc.target/i386/adx-addcarryx64-2.c b/gcc/testsuite/gcc.target/i386/adx-addcarryx64-2.c index 6aa2539c0d1..b326291bb35 100644 --- a/gcc/testsuite/gcc.target/i386/adx-addcarryx64-2.c +++ b/gcc/testsuite/gcc.target/i386/adx-addcarryx64-2.c @@ -22,6 +22,33 @@ adx_test (void) 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 (); } diff --git a/gcc/testsuite/gcc.target/i386/adx-addcarryx64-3.c b/gcc/testsuite/gcc.target/i386/adx-addcarryx64-3.c index 4bbf74bfc2d..9d9809d74fe 100644 --- a/gcc/testsuite/gcc.target/i386/adx-addcarryx64-3.c +++ b/gcc/testsuite/gcc.target/i386/adx-addcarryx64-3.c @@ -1,6 +1,7 @@ /* { 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 @@ -12,4 +13,6 @@ void extern adx_test (void) { c = _addcarryx_u64 (c, x, y, sum); + c = _addcarry_u64 (c, x, y, sum); + c = _subborrow_u64 (c, x, y, sum); } -- 2.30.2