<div class="gmail_quote">On 23 October 2011 07:15, Duncan Sands <span dir="ltr"><<a href="mailto:baldrick@free.fr">baldrick@free.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Nick,<br>
<div class="im"><br>
> - if (const CmpInst *CI = dyn_cast<CmpInst>(I))<br>
> + if (CmpInst *CI = dyn_cast<CmpInst>(I))<br>
> return ConstantFoldCompareInstOperands(CI->getPredicate(), Operands[0],<br>
> Operands[1], TD);<br>
> + if (LoadInst *LI = dyn_cast<LoadInst>(I)) {<br>
> + if (!LI->isVolatile())<br>
> + return ConstantFoldLoadFromConstPtr(Operands[0], TD);<br>
> + }<br>
> return ConstantFoldInstOperands(I->getOpcode(), I->getType(), Operands, TD);<br>
<br>
</div>maybe you could use instsimplify here? It does constant folding and more<br>
besides. It can break LCSSA form, so y so,<br>
check out the loop transform users of instsimplify to seou may need to check for that (ife how).</blockquote><div><br></div><div>As far as I can see, LCSSA isn't documented and I don't understand it well enough to know whether I'm preserving it or breaking it etc. I know it involves creating 1-operand PHI nodes in strategic places and that's about it.</div>
<div><br></div><div>Are there cases where InstructionSimplify will return a Constant that the constant folder won't? This code is entirely based off of a mapping to Constant*, so instsimplify won't help without more refactoring.</div>
<div><br></div><div>That refactoring would be scary because while we can represent the arbitrary values, we'll find ourselves effectively unrolling the loop as we build up a larger and larger SCEV expression. I'd like to leave unrolling to the unrolling pass.</div>
<div><br></div><div>Nick</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">> @@ -4993,7 +5109,10 @@<br>
> if (const CmpInst *CI = dyn_cast<CmpInst>(I))<br>
> C = ConstantFoldCompareInstOperands(CI->getPredicate(),<br>
> Operands[0], Operands[1], TD);<br>
> - else<br>
> + else if (const LoadInst *LI = dyn_cast<LoadInst>(I)) {<br>
> + if (!LI->isVolatile())<br>
> + C = ConstantFoldLoadFromConstPtr(Operands[0], TD);<br>
> + } else<br>
> C = ConstantFoldInstOperands(I->getOpcode(), I->getType(),<br>
> Operands, TD);<br>
> if (!C) return V;<br>
<br>
</div>Likewise.<br>
<br>
Ciao, Duncan.<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br>