On Tue, 31 Jul 2012, Richard Henderson wrote:

> On 2012-07-31 02:09, Richard Guenther wrote:
> > What do we expect __builtin_compare_exchange to do for
> > unaligned inputs?
> 
> At the moment we expect it to SIGBUS, as a rule.
> 
> We'd *like* to defer to the library routine for unaligned,
> but we don't do that yet.

I see.  So your issue is that you don't get the knowledge
that the address is even more aligned than required by the
builtin.

> Too bad about not being able to query addresses/ssa_names
> for their alignment; I thought we could do that already.

We can - just we cannot rely on type information for addresses,
mainly because people write non-conforming C code all the time
(and thus we settled on their side for middle-end semantics).
On x86_64 it's common to do

int foo (int *p)
{
   if ((uintptr_t)p & 3)
     return 0;
   return *p;
}

and if we'd use type information for 'p' then we'd optimize away
the alignment test ...

So we only use type information when seeing an actual memory
reference where we make sure to keep alignment info correct
(which we don't bother to do for addresses).

Richard.

Reply via email to