<div dir="ltr"><div><div>David, thank you for the prompt response.<br></div>I originally implemented this with a check of getAlignment(). However, both getAlignment() and getOriginalAlignment() on the <4 x i32> load return the stronger alignment (16) rather than the alignment that the i32* parameter would have (4).<br><br></div>So I am a bit stuck in terms of how to verify the original alignment.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 26, 2016 at 3:26 PM, David Chisnall <span dir="ltr"><<a href="mailto:David.Chisnall@cl.cam.ac.uk" target="_blank">David.Chisnall@cl.cam.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 26 Dec 2016, at 14:58, Nemanja Ivanovic via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
><br>
> I am wondering if there is a good/easy way to recover the original type of a pointer parameter in the SDAG. Here's the problem that I am dealing with:<br>
><br>
> define <4 x i32> @test(i32* nocapture readonly %a) local_unnamed_addr #0 {<br>
> entry:<br>
> %0 = bitcast i32* %a to <4 x i32>*<br>
> %1 = load <4 x i32>, <4 x i32>* %0, align 16, !tbaa !2<br>
> ret <4 x i32> %1<br>
> }<br>
><br>
> The problem is that the alignment requirements on my target for a load of an i32* are different from those on a <4 x i32>*. I don't see a way to specify that with the DataLayout and when the SelectionDAG is built, the bitcast goes away because both the source and destination types are the same (i64 according to the DataLayout).<br>
><br>
> So I end up with this as the initial SDAG:<br>
> Initial selection DAG: BB#0 'test:entry'<br>
> SelectionDAG has 9 nodes:<br>
> t0: ch = EntryToken<br>
> t3: i64 = Constant<0><br>
> t2: i64,ch = CopyFromReg t0, Register:i64 %vreg0<br>
> t5: v4i32,ch = load<LD16[%0](tbaa=<<wbr>0x10038f18a98>)> t0, t2, undef:i64<br>
> t7: ch,glue = CopyToReg t0, Register:v4i32 %V2, t5<br>
> t8: ch = PPCISD::RET_FLAG t7, Register:v4i32 %V2, t7:1<br>
><br>
> What I would like to do is emit efficient code for cases where the parameter pointer has the same alignment requirements as the load and emit the conservative but less efficient code in other cases.<br>
<br>
</span>Do you actually need to know the original type for this? Isn’t it enough to know the alignment? The getAlignment() / getOriginalAlignment() methods on the LoadSDNode should give you this.<br>
<span class="HOEnZb"><font color="#888888"><br>
David<br>
<br>
</font></span></blockquote></div><br></div>