<div dir="ltr">On Fri, Aug 16, 2013 at 7:51 AM, Daniel Sanders <span dir="ltr"><<a href="mailto:Daniel.Sanders@imgtec.com" target="_blank">Daniel.Sanders@imgtec.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div link="blue" vlink="purple" lang="EN-GB">
<div>
<p class="MsoNormal">Hi,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">From <a href="http://llvm.org/docs/LangRef.html#bitcast-to-instruction" target="_blank">http://llvm.org/docs/LangRef.html#bitcast-to-instruction</a>:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal" style="margin-left:36.0pt">The ‘bitcast‘ instruction converts value to type ty2. It is always a no-op cast because no bits change with this conversion. The conversion is done as if the value had been stored to memory and read back as type
ty2. Pointer (or vector of pointers) types may only be converted to other pointer (or vector of pointers) types with this instruction if the pointer sizes are equal. To convert pointers to other types, use the inttoptr or ptrtoint instructions first.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">If I understand the definition correctly, then:<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New"">%1 = bitcast <8 x i16> %0 to <4 x i32><u></u><u></u></span></p>
<p class="MsoNormal">Should be equivalent to:<u></u><u></u></p>
<p class="MsoNormal"> <span style="font-family:"Courier New"">store <8 x i16> %0, <8 x i16>* %ptr<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New"">%1 = load <4 x i32>* %ptr<u></u><u></u></span></p>
<p class="MsoNormal">Which the definition above asserts is a no-op cast. However, the store/load sequence is not a no-op cast for vector types when the target does not treat the whole vector as either little or big-endian. MIPS MSA stores vector elements in
big or little endian order according to a configuration bit, but irrespective of this bit the lanes are stored in ascending order. For example, <4 x i32> <i32 1, i32 2, i32 3, i32 4> would be stored as this in big-endian mode:<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New"">%ptr : 00 00 00 01<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New"">%ptr+4 : 00 00 00 02<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New"">%ptr+8 : 00 00 00 03<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New"">%ptr+12: 00 00 00 04<u></u><u></u></span></p>
<p class="MsoNormal">And this in little-endian mode:<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New"">%ptr : 01 00 00 00<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New"">%ptr+4 : 02 00 00 00<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New"">%ptr+8 : 03 00 00 00<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New"">%ptr+12: 04 00 00 00<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">How should I resolve this conflicting definition?<u></u><u></u></p>
<p class="MsoNormal" style="text-align:justify"> </p><p class="MsoNormal" style="text-align:justify"><br></p></div></div></blockquote><div><br></div><div>It's a "no-op" cast in the sense that there isn't any math involved; it's not a statement about the number of necessary machine instructions.<br>
</div></div><br></div><div class="gmail_extra">-Eli<br></div></div>