Razya Ladelsky wrote:
Hi,

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);
}

Here's the failure message:

error: unrecognizable insn:
(insn 16 15 17 3 (parallel [
            (set (reg:SI 123)
(ior:SI (and:SI (plus:SI (mem/v:QI (reg/f:SI 115 virtual-stack-vars) [-1 S1 A64])

I wonder why you are setting a SImode regester when doing a QImode fetch_and_add operation. Perhaps the compiler is trying to keep uc in a register which would not make sense for an atomic memory operation. Perhaps the insn predicates and/or constraints need to be adjusted so that the operand is forced into memory.

David Daney

Reply via email to