<div dir="ltr">Thanks Mats. Yes, it currently leads to "Illegal BitCast". Can I change the pInst directly to generate the code I want?</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 15, 2015 at 2:13 PM, mats petersson <span dir="ltr"><<a href="mailto:mats@planetcatfish.com" target="_blank">mats@planetcatfish.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">So, you need to bitcast `pinst` to a pointer to Vector of double,<br>
since it (I hope for your sake) is a pointer to integer. What you are<br>
trying to do is bitcast a pointer into a vector, which probably will<br>
lead to an assert or "bad code that doesn't work".<br>
<br>
--<br>
Mats<br>
<div class="HOEnZb"><div class="h5"><br>
On 15 April 2015 at 21:57, zhi chen <<a href="mailto:zchenhn@gmail.com">zchenhn@gmail.com</a>> wrote:<br>
> What I want to do is to change the pInst from : 2%= load double* %1, align 8<br>
> to 2% = load < 2 x double>* %1, align 16, where <2 x double> should be two<br>
> double identical double values that is same as the one in the previous<br>
> instruction<br>
><br>
> Instruction* ScalarToVectorLoad(Instruction* pInst) {<br>
>   Value *loadValue = pInst->getOperand(0);<br>
>   Instruction *newLoad;   //this one should be 2% = load < 2 x double>* %1<br>
><br>
>   BitCastInst *scalarToVector = new BitCastInst(loadValue,<br>
> VectorType::get(Type::getDoubleTy(currF->getContext()), 2),<br>
> "vectorizedLoad", pInst);<br>
>   newLoad = new LoadInst(); //to be implemented...<br>
>   return newLoad;<br>
> }<br>
><br>
> On Wed, Apr 15, 2015 at 1:03 PM, mats petersson <<a href="mailto:mats@planetcatfish.com">mats@planetcatfish.com</a>><br>
> wrote:<br>
>><br>
>> Create a type that is a "vector (array) of 2 double", and then a<br>
>> pointer to that. Now use bitcast your on double pointer to that<br>
>> pointer type you've created, and then create a load...<br>
>><br>
>> If you need more help, it would help if you post the code you are working<br>
>> on...<br>
>><br>
>> --<br>
>> Mats<br>
>><br>
>> On 15 April 2015 at 19:51, zhi chen <<a href="mailto:zchenhn@gmail.com">zchenhn@gmail.com</a>> wrote:<br>
>> > How can I write code to generate IR for:<br>
>> > %2 = bitcast double* %1 to <2 x double>*.<br>
>> > %3 = load <2 x double>* %2, align 16<br>
>> > Basically, it is similar to x86 _mm_load_pd1 intrinsics.<br>
>> ><br>
>> > Thanks,<br>
>> > Zhi<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>
><br>
</div></div></blockquote></div><br></div>