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: [PATCH, PR43814] Assume function arguments of pointer type are aligned.


On Wed, Sep 28, 2011 at 10:08 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Wed, Sep 28, 2011 at 09:56:27PM +0200, Richard Guenther wrote:
>> There is nothing like "very likely aligned" ;) ?Note that what is new is
>
> On non-strict aligned targets there is no reason not to have something like
> "very likely aligned". ?You would expand stores/loads as if it was aligned
> in that case, and if it isn't, all you'd need to ensure from that is that
> you don't derive properties about the pointer value from the "likely
> aligned" info, only from alignment.

As if aligned, say, using movaps? ;)  Then we can as well derive
properties about the pointer value.

Note that I don't see a real difference between expanding a load/store
assuming the pointer is aligned from deriving properties about the pointer
value.  To support existing questionable code I'd do both only if
there is a dereference post-dominating the pointer assignment of course.

> "Very likely aligned" is interesting to the vectorizer too, if it is very
> likely something is sufficiently aligned, the vectorizer could decide to
> assume the alignment in the vectorized loop and add the check for the
> alignment to the loop guards. ?In the likely case the vectorized loop would
> be used (if other guards were true too), in the unlikely case it is
> unaligned it would just use a slower loop.
>
>> that we now no longer assume alignment by default (we did in the past)
>> and that we derive properties about the pointer _value_ from alignment.
>>
>> I think we can derive pointer values when we see dereferences, the
>> code wouldn't be portable to strict-alignment targets otherwise. ?We
>
> But any references? ?If you have
> int foo (int *p)
> {
> ?memcpy (p, "a", 1);
> ?return ((uintptr_t) p & 3) == 0;
> }
> then even if p isn't aligned, this could work even on strict aligned
> targets.

Well, the above isn't a "dereference".  Or rather, if it is, it's a dereference
through a type with assumed alignment of 1 byte.

> Anyway, the arbitrary value in a pointer thing is much more important then
> the rest, so having the dominating dereference test is very important.

Yes.

Richard.

> ? ? ? ?Jakub
>


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