This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: sync_fetch_and_add creating unrecognizable insn
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Razya Ladelsky <RAZYA at il dot ibm dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 29 Aug 2007 15:04:50 -0400
- Subject: Re: sync_fetch_and_add creating unrecognizable insn
- References: <OFC9B37244.6A0AA62A-ONC2257346.004704EE-C2257346.00474638@il.ibm.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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