<div class="gmail_quote">On Tue, Jul 14, 2009 at 8:10 PM, Bill Wendling <span dir="ltr"><<a href="mailto:isanbard@gmail.com">isanbard@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="h5">On Tue, Jul 14, 2009 at 2:53 AM, Anton Korobeynikov<<a href="mailto:asl@math.spbu.ru">asl@math.spbu.ru</a>> wrote:<br>
> Author: asl<br>
> Date: Tue Jul 14 04:53:14 2009<br>
> New Revision: 75629<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=75629&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=75629&view=rev</a><br>
> Log:<br>
> Add extra sign extension to the same bit width before int sign<br>
> extension to another bit width. This is needed to get correct singed value.<br>
> Patch by Artur Pietrek!<br>
><br>
> Modified:<br>
>    llvm/trunk/lib/Target/MSIL/MSILWriter.cpp<br>
>    llvm/trunk/lib/Target/MSIL/MSILWriter.h<br>
><br>
> Modified: llvm/trunk/lib/Target/MSIL/MSILWriter.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSIL/MSILWriter.cpp?rev=75629&r1=75628&r2=75629&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSIL/MSILWriter.cpp?rev=75629&r1=75628&r2=75629&view=diff</a><br>

><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/Target/MSIL/MSILWriter.cpp (original)<br>
> +++ llvm/trunk/lib/Target/MSIL/MSILWriter.cpp Tue Jul 14 04:53:14 2009<br>
> @@ -670,12 +670,18 @@<br>
><br>
><br>
>  void MSILWriter::printCastInstruction(unsigned int Op, const Value* V,<br>
> -                                      const Type* Ty) {<br>
> +                                      const Type* Ty, const Type* SrcTy) {<br>
>   std::string Tmp("");<br>
>   printValueLoad(V);<br>
>   switch (Op) {<br>
>   // Signed<br>
>   case Instruction::SExt:<br>
> +    // If sign extending int, convert first from unsigned to signed<br>
> +    // with the same bit size - because otherwise we will loose the sign.<br>
> +    if (SrcTy) {<br>
> +      Tmp = "conv."+getTypePostfix(SrcTy,false,true);<br>
> +      printSimpleInstruction(Tmp.c_str());<br>
> +    }<br>
>   case Instruction::SIToFP:<br>
>   case Instruction::FPToSI:<br>
<br>
</div></div>If this fall-through is expected, could you place a comment there saying so?<br>
<font color="#888888"><br>
-bw</font><br></blockquote></div><br>Yes, it is. I'll submit patch with comment tomorrow, I'm away from my PC (and files) right now.<br><br>Artur<br>