Would it be possible to replace all uses of the i64 (bitcast Instruction) with bitcast operand? <br><br>So for something like: tmp = bitcast %struct.MyStruct* %arrayidx to i64*<br><br>I would like to replace all uses of tmp with arrayidx. It doesn't look like LLVM has a way to setType() so I guess I would have to check uses, and create new instructions of the StructTy and replace those uses with the new Instruction?<br>
<br><div class="gmail_quote">On Thu, Jun 28, 2012 at 3:27 PM, Eli Friedman <span dir="ltr"><<a href="mailto:eli.friedman@gmail.com" target="_blank">eli.friedman@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Thu, Jun 28, 2012 at 3:04 PM, Ryan Taylor <<a href="mailto:ryta1203@gmail.com">ryta1203@gmail.com</a>> wrote:<br>
> I have some C code that does a memcpy (though it doesn't use the memcpy<br>
> instrinsic at all) on structure like:<br>
><br>
> x = y;<br>
><br>
> Where x and y are of the same structure type. My question is in the LLVM<br>
> code, it firsts get the address from the GEP using the struct type but then<br>
> before the load and store, it bitcasts this to i64 for some reason?<br>
><br>
> Why does this occur in the IR? Doesn't seem like the IR would care either<br>
> way.<br>
<br>
</div>instcombine will transform the memcpy intrinsic into an i64<br>
load+store. The heuristics instcombine uses to subsequently convert<br>
the load to a different type are very conservative, so it often won't<br>
get transformed after that. Also, instcombine will never generate a<br>
load of a pointer to a struct because the code generator doesn't<br>
handle the construct well.<br>
<div class="im"><br>
> Just to clarify any confusion, I'm not talking about the pointer width, I'm<br>
> talking about the type that the pointer is pointing to.<br>
><br>
> Thanks.<br>
><br>
> Also, is there anyway to make LLVM do an element by element copy in this<br>
> case?<br>
<br>
</div>You could try hacking the frontend... but the optimizer is likely to<br>
merge the operations together again.<br>
<span class="HOEnZb"><font color="#888888"><br>
-Eli<br>
</font></span></blockquote></div><br>