Unoptimized IR<br><br><br>
%tmp63 = call %struct.TypHeader* (...)* bitcast (%struct.TypHeader*<br>
(%struct.TypHeader*, i64, i64)* @Cyclotomic to %struct.TypHeader*<br>
(...)*)(%struct.TypHeader* %tmp62, i64 %tmp24, i32 1) nounwind, !dbg !907 ;<br>
<%struct.TypHeader*> [#uses=1]<br><br>Optimized IR<br><br><br> %tmp63 = call%struct.TypHeader*<br>
(%struct.TypHeader*, i64, i64)* @Cyclotomic (%struct.TypHeader* %tmp62, i64 %tmp24, i64 1) nounwind<br>
<%struct.TypHeader*> [#uses=1] <br><br>The way InstCombine manages this, is (from InstCombineCalls.cpp:1039)<br><br> if ((*AI)->getType() == ParamTy) {<br> Args.push_back(*AI);<br> } else {<br> Instruction::CastOps opcode = CastInst::getCastOpcode(*AI,<br>
false, ParamTy, false);<br> Args.push_back(Builder->CreateCast(opcode, *AI, ParamTy, "tmp"));<br> }<br><br>When it asks for the castOpcode, it assumes both types are unsigned(indicated by the false arguments).<br>
<br>Is it correct to assume this?<br><br>Thanks,<br>Arushi<br><br><div class="gmail_quote">On Tue, Apr 5, 2011 at 1:57 PM, Arushi Aggarwal <span dir="ltr"><<a href="mailto:arushi987@gmail.com">arushi987@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><br><br><div class="gmail_quote"><div class="im">On Tue, Apr 5, 2011 at 1:44 PM, Duncan Sands <span dir="ltr"><<a href="mailto:baldrick@free.fr" target="_blank">baldrick@free.fr</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi Arushi,<div><br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
%tmp63 = call %struct.TypHeader* (...)* bitcast (%struct.TypHeader*<br>
(%struct.TypHeader*, i64, i64)* @Cyclotomic to %struct.TypHeader*<br>
(...)*)(%struct.TypHeader* %tmp62, i64 %tmp24, i32 1) nounwind, !dbg !907 ;<br>
<%struct.TypHeader*> [#uses=1]<br>
<br>
the 3rd parameter is now used in an srem statement. How do we know what value is<br>
used? Does this use decide whether the value is sign extended or zero extended?<br>
</blockquote>
<br></div>
inside the called function the 3rd value will contain rubbish. That's because<br>
the function takes an i64 parameter but via the bitcast you pretend it takes an<br>
i32 parameter, which is wrong. This is not the correct way to pass an i32 to a<br>
function that takes an i64. Where did you get this IR from?<br></blockquote></div><div><br>This is unoptimized IR, generated for a SPEC example.<br><br>The optimized IR, converts this call to <br><br> %tmp63 = call%struct.TypHeader*<br>
(%struct.TypHeader*, i64, i64)* @Cyclotomic (%struct.TypHeader* %tmp62, i64 %tmp24, i64 1) nounwind<br>
<%struct.TypHeader*> [#uses=1] <br><br>I was just wondering what the logic was to infer when such conversions could be made.<br></div><div class="im"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
Ciao, Duncan.<br>
<br>
PS: It may not contain rubbish in practice, in particular probably the lower 32<br>
bits will have the "right" value, but nothing guarantees that.<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div>
<br>
Arushi<br>
<br>
On Tue, Apr 5, 2011 at 1:35 AM, Duncan Sands <<a href="mailto:baldrick@free.fr" target="_blank">baldrick@free.fr</a><br></div><div>
<mailto:<a href="mailto:baldrick@free.fr" target="_blank">baldrick@free.fr</a>>> wrote:<br>
<br>
Hi Arushi,<br>
<br>
> For a call like this,<br>
><br>
> %tmp6 = call i32 (...)* bitcast (i32 (i8*, i8, i8**)* @ssplit to i32<br>
(...)*)(i8*<br>
> %tmp599, i32 46, i8** %domainv3) nounwind ; <i32><br>
><br>
> does the 2nd argument get zero extended or sign extended?<br>
<br>
neither since it does not have the zext or sext attribute.<br>
<br>
Ciao, Duncan.<br>
_______________________________________________<br>
LLVM Developers mailing list<br></div>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a> <mailto:<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><div>
<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>
</div></blockquote>
<br>
</blockquote></div></div><br>
</blockquote></div><br>