[patch] fix sync builtin expansion and i386 pattern
Michael Matz
matz@suse.de
Mon Mar 19 18:05:00 GMT 2007
Hi,
On Fri, 16 Mar 2007, Ian Lance Taylor wrote:
> > * builtins.c (expand_builtin_sync_operation,
> > expand_builtin_compare_and_swap,
> > expand_builtin_lock_test_and_set): Care for extending CONST_INTs
> > correctly.
> >
> > * config/i386/sync.md (sync_double_compare_and_swapdi_pic,
> > sync_double_compare_and_swap_ccdi_pic): Use "SD" as constraint
> > for operand 3.
>
> This is OK for mainline.
committed (after testing on x86-64-linux succeeded).
> It's OK for 4.1 and 4.2 if it is a regression (I've lost track). If
> it's not a regression, check with Mark on the backport.
Mark: I don't know if it's a regression, I believe the incorrect code was
there since the introduction of __sync_* builtins, which would make it a
non-regression. The failure mode is, that calls like
unsigned long long *ptr;
__sync_fetch_and_add (ptr, -1LL);
__sync_compare_and_swap (ptr, a, -1LL);
would be miscompiled, the 64 bit -1 would be represented as 0xffffffff. I
have no feeling how often that is actually used in real code (or how often
the __sync_* builtins are used at all), especially how often any constant
arguments would be -1LL instead of e.g. just 0 or 1 (which both would be
represented correctly).
There's another miscompilation on x86, also only involving 64bit atomic
primitives, which also leads to misrepresented 64bit constants.
Ciao,
Michael.
More information about the Gcc-patches
mailing list