<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 11, 2015, at 3:54 PM, Eric Christopher <<a href="mailto:echristo@gmail.com" class="">echristo@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><br class=""><br class=""><div class="gmail_quote">On Wed Feb 11 2015 at 3:52:06 PM Mehdi Amini <<a href="mailto:mehdi.amini@apple.com" class="">mehdi.amini@apple.com</a>> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">+  Instruction *OpI = cast<Instruction>(FI.<u class=""></u>getOperand(0));<br class="">
+  if (!isa<UIToFPInst>(OpI) && !isa<SIToFPInst>(OpI))<br class="">
+    return nullptr;<br class="">
<br class="">
You are using isa<>() on the result of an unsafe cast, it makes me nervous and I don’t know if it is safe this way.<br class="">
<br class=""></blockquote><div class=""><br class=""></div><div class="">if (Instruction *Op1 = dyn_cast<Instruction>(FI.getOperand(0)) &&</div><div class="">    ...)</div><div class=""><br class=""></div><div class="">should work?</div></div></div></div></blockquote><div><br class=""></div><div>I don’t think it is possible in C++.</div><div>You would need to add parenthesis around the assignment (precedence of assignment is lower than the one of logical operators), and if you do that the declaration is no longer valid.</div><div><br class=""></div><div>And the dyn_cast is a spurious check anyway, to be able to replace it with a cast, you need to do it after the sanity check:</div><div><br class=""></div><div>auto &Op = FI.getOperand(0);</div><div>if (!isa<UIToFPInst>(Op) && !isa<SIToFPInst>(Op))<br class="">  return nullptr;<br class="">Instruction *OpI = cast<Instruction>(Op);</div><div><br class=""></div><div><br class=""></div><div>— </div><div>Mehdi</div><div><br class=""></div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_quote"><div class=""><br class=""></div><div class="">-eric</div><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+        return new SExtInst(OpI->getOperand(0), FITy);<br class="">
+      else<br class="">
<br class="">
You didn’t fix this.<br class="">
<br class="">
—<br class="">
Mehdi<br class="">
<br class="">
<br class="">
> On Feb 11, 2015, at 3:39 PM, Fiona Glaser <<a href="mailto:fglaser@apple.com" target="_blank" class="">fglaser@apple.com</a>> wrote:<br class="">
><br class="">
> Patch updated based on comments.<br class="">
><br class="">
> Fiona<br class="">
><br class="">
> <floatcvtfold.diff><br class="">
<br class="">
<br class="">
______________________________<u class=""></u>_________________<br class="">
llvm-commits mailing list<br class="">
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank" class="">llvm-commits@cs.uiuc.edu</a><br class="">
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank" class="">http://lists.cs.uiuc.edu/<u class=""></u>mailman/listinfo/llvm-commits</a><br class="">
</blockquote></div></div>
</div></blockquote></div><br class=""></body></html>