This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: sync_fetch_and_add creating unrecognizable insn


On Wed, Aug 29, 2007 at 03:59:05PM +0300, Razya Ladelsky wrote:
> When passing an address of a local variable as the first argument of 
> 'sync_fetch_and_add' 
> I get an error of unrecognizable insn.
> For example, the test below (extracted from 
> gcc.c-torture/compile/sync-1.c) fails on powerpc.
> If however, 'uc' was a global variable, the compilation passed perfectly.
> This scenario does not happen for ints, only for chars.
> 
> void test_op_ignore (void)
> {
>   unsigned char uc;
>   (void) __sync_fetch_and_add (&uc, 1);
> }

This should fix it, though haven't regtested it yet nor tried to
come up with some testcases, will do so tomorrow:

--- gcc/config/rs6000/rs6000.c.jj	2007-08-25 09:06:46.000000000 +0200
+++ gcc/config/rs6000/rs6000.c	2007-08-29 20:31:08.000000000 +0200
@@ -12757,6 +12757,7 @@ rs6000_emit_sync (enum rtx_code code, en
 	    ishift = GET_MODE_BITSIZE (SImode) - GET_MODE_BITSIZE (mode);
 
 	  shift = GEN_INT (ishift);
+	  used_m = adjust_address (used_m, SImode, 0);
 	}
       else
 	{
@@ -12777,14 +12778,14 @@ rs6000_emit_sync (enum rtx_code code, en
 				       1, OPTAB_LIB_WIDEN);
 	  used_m = change_address (used_m, SImode, aligned_addr);
 	  set_mem_align (used_m, 32);
-	  /* It's safe to keep the old alias set of USED_M, because
-	     the operation is atomic and only affects the original
-	     USED_M.  */
-	  if (GET_CODE (m) == NOT)
-	    m = gen_rtx_NOT (SImode, used_m);
-	  else
-	    m = used_m;
 	}
+      /* It's safe to keep the old alias set of USED_M, because
+	 the operation is atomic and only affects the original
+	 USED_M.  */
+      if (GET_CODE (m) == NOT)
+	m = gen_rtx_NOT (SImode, used_m);
+      else
+	m = used_m;
 
       if (GET_CODE (op) == NOT)
 	{


	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]