<div class="gmail_quote">On 21 January 2011 12:56, Douglas do Couto Teixeira <span dir="ltr"><<a href="mailto:douglasdocouto@gmail.com" target="_blank">douglasdocouto@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


Hello guys,<br><br>I wonder how I can change the type of an integer variable. For instance, given the instruction "%3 = add i32 %1, %2" I would like to alter the instruction to "%3 = add i16 %1, %2". Is there any way to do this?<br>


</blockquote><div><br></div><div>No. Instead you create a new Instruction, in this case with BinaryOperator::CreateAdd, then OldInst->replaceAllUsesWith(NewInst) to update all the users, then OldInst->eraseFromParent() since it's now dead code.</div>

<div><br></div>
<div>Also, all values have types immutably assigned at creation, so you'll need to insert casts (trunc instructions in your case) to cast %1 and %2 from i32 to i16 for the smaller add.</div><div><br></div><div>Nick</div>


<div><br></div></div>