[PATCH] sync builtin testcase: Add alignment attribute on TImode variable

2014-02-07 Thread Andreas Krebbel
Hi,

the S/390 expanders reject operands not being naturally aligned.  This
makes the gcc-have-sync-compare-and-swap.c failing.

The attached patch adds an alignment attribute to the data
type used in the check to make it succeed on S/390 again.

In the future perhaps it would be more appropriate to introduce a 128
bit data type supposed to be used for atomic operations.  Given that
we already have __int128_t perhaps we should also provide a
__atomic_int128_t?  For S/390 we cannot change the alignment of
__int128_t anymore but we would require a stricter alignment for
__atomic_int128_t right from the beginning in order to enable our
atomic hardware instructions.  Does that sound reasonable?

Ok for mainline?

Bye,

-Andreas-


2014-02-07  Andreas Krebbel  andreas.kreb...@de.ibm.com

* gcc.dg/gcc-have-sync-compare-and-swap.c: Align the 16 byte
variable used for atomic operations.


commit 4b91700e39db14f474b030956b14be94794b589c
Author: Andreas Krebbel kreb...@linux.vnet.ibm.com
Date:   Fri Feb 7 13:59:47 2014 +0100

Add alignment attribute to 128 bit type for atomic operations.

diff --git a/gcc/testsuite/gcc.dg/gcc-have-sync-compare-and-swap.c 
b/gcc/testsuite/gcc.dg/gcc-have-sync-compare-and-swap.c
index faed818..5affeba 100644
--- a/gcc/testsuite/gcc.dg/gcc-have-sync-compare-and-swap.c
+++ b/gcc/testsuite/gcc.dg/gcc-have-sync-compare-and-swap.c
@@ -40,10 +40,12 @@ void f8()
 #endif
 }
 
+/* aligned (16): On S/390 16 byte compare and swap operations are only
+   available if the memory operand resides on a 16 byte boundary.  */
 void f16()
 {
 #ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16
-  typedef int __attribute__ ((__mode__ (__TI__))) ti_int_type;
+  typedef int __attribute__ ((__mode__ (__TI__), aligned (16))) ti_int_type;
   ti_int_type ti_int;
   __sync_bool_compare_and_swap (ti_int, (ti_int_type)0, (ti_int_type)1);
 #endif



Re: [PATCH] sync builtin testcase: Add alignment attribute on TImode variable

2014-02-07 Thread Jakub Jelinek
On Fri, Feb 07, 2014 at 02:12:44PM +0100, Andreas Krebbel wrote:
 2014-02-07  Andreas Krebbel  andreas.kreb...@de.ibm.com
 
   * gcc.dg/gcc-have-sync-compare-and-swap.c: Align the 16 byte
   variable used for atomic operations.

Ok.

 --- a/gcc/testsuite/gcc.dg/gcc-have-sync-compare-and-swap.c
 +++ b/gcc/testsuite/gcc.dg/gcc-have-sync-compare-and-swap.c
 @@ -40,10 +40,12 @@ void f8()
  #endif
  }
  
 +/* aligned (16): On S/390 16 byte compare and swap operations are only
 +   available if the memory operand resides on a 16 byte boundary.  */
  void f16()
  {
  #ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16
 -  typedef int __attribute__ ((__mode__ (__TI__))) ti_int_type;
 +  typedef int __attribute__ ((__mode__ (__TI__), aligned (16))) ti_int_type;
ti_int_type ti_int;
__sync_bool_compare_and_swap (ti_int, (ti_int_type)0, (ti_int_type)1);
  #endif

Jakub