<div dir="ltr">Related to this subject is the __attribute__(aligned(X)) that can be set on a type in C/C++. It is being used when generating the load / stores / memcpy / ... but is lost with respect to the type's attribute. In many a case this could help various analysis or transforms to provide more accurate results when such a type is used. The __builtin_assume_aligned could be an way to solve this.<div>
<br></div><div>Cheers,</div><div>--</div><div>Arnaud</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Mar 25, 2014 at 4:22 PM, Hal Finkel <span dir="ltr"><<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">----- Original Message -----<br>
> From: "Frank Winter" <<a href="mailto:fwinter@jlab.org">fwinter@jlab.org</a>><br>
> To: <a href="mailto:llvmdev@cs.uiuc.edu">llvmdev@cs.uiuc.edu</a><br>
> Sent: Tuesday, March 25, 2014 9:23:59 AM<br>
> Subject: Re: [LLVMdev] Alignment of pointee<br>
><br>
> On 03/25/2014 10:08 AM, Krzysztof Parzyszek wrote:<br>
> > On 3/25/2014 8:53 AM, Frank Winter wrote:<br>
> >><br>
> >> One can see that if the initial alignment of the pointee of %arg0<br>
> >> was 32<br>
> >> bytes and since the vectorizer operates on a loop with a fixed<br>
> >> trip<br>
> >> count of 4 and the size of double is 8 bytes, the vector loads and<br>
> >> stores could be ideally aligned with 32 bytes (which on my target<br>
> >> architecture would result in vector loads without additional<br>
> >> permutations.<br>
> >><br>
> >> Is it somehow possible to achieve this? I am generating the IR<br>
> >> with the<br>
> >> builder, i.e. I am not coming from C or clang.<br>
> ><br>
> > If you are generating the loads and stores, you could just set the<br>
> > alignment to whatever you want, i.e. 32 bytes in your case.<br>
> I can't. Take a look again at the first piece of code. The loads<br>
> occur<br>
> in the 'inner' loop. Only for the first iteration the alignment of 32<br>
> bytes is true, not for iteration 2, 3 and 4. So, the alignment<br>
> information cannot enter at the point of loading. Thus, the idea of<br>
> attaching the information right at the pointer's definition, i.e. as<br>
> the<br>
> argument.<br>
<br>
</div></div>I had a patchset that I had posted for review some months (a year?) ago to implement __builtin_assume_aligned. This ended up side-tracked in a discussion re: generalized invariants. We should, however, certainly revisit this soon.<br>

<br>
 -Hal<br>
<div class="im HOEnZb"><br>
> ><br>
> > I have wondered about it in a general case, when you simply want to<br>
> > have an alignment information on the pointer, and not on<br>
> > loads/stores.  My idea was to invent a builtin, something like<br>
> > "assert_aligned", that does nothing, other than manifest the<br>
> > alignment<br>
> > by the fact of its existence. For example:<br>
> >   %argp = call i8* llvm.assert.aligned(%arg0, 32)<br>
> > would state that the pointer %argp is aligned to 32 bytes, and the<br>
> > value of it is the same as %arg0 at the place of the "call".<br>
> ><br>
> > That was a while ago and maybe there are other ways of doing it<br>
> > now.<br>
> Should be doable this way. Although I am not sure whether a assertion<br>
> or<br>
> an annotation would be cleaner.<br>
><br>
> There should already be a solution.<br>
> ><br>
> > -Krzysztof<br>
> ><br>
><br>
><br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
><br>
<br>
</div><span class="HOEnZb"><font color="#888888">--<br>
Hal Finkel<br>
Assistant Computational Scientist<br>
Leadership Computing Facility<br>
Argonne National Laboratory<br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br></div>