<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Unfortunately, CFP is an SDNode: the assignment statement with dyncast ends up calling the SDValue's *operator. I could probably call the SDValue constructor on CFP, and in that case would the resno just be 0?<div><br><div><div>On Sep 7, 2012, at 4:59 PM, Chandler Carruth <<a href="mailto:chandlerc@google.com">chandlerc@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 7, 2012 at 7:55 PM, Michael Ilseman <span dir="ltr"><<a href="mailto:milseman@apple.com" target="_blank" class="cremed">milseman@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Thanks for the comment. New patch attached. I'm not too familiar with SDValue/SDNode, so if you see a way that it can be cleaned up further, let me know!</div>
</blockquote><div><br></div><div>Hmm, I would have assumed (naively, and without running the compiler over it) that you could write this as:</div><div><br></div><div><div>      } else if (Opcode == ISD::FMUL) {</div><div>
        ConstantFPSDNode *CFP = dyn_cast<ConstantFPSDNode>(N1);</div><div>        SDNode *Arg = N2;</div><div><br></div><div>        // If the first operand isn't the constant, try the second</div><div>        if (!CFP) {</div>
<div>          CFP = dyn_cast<ConstantFPSDNode>(N2);</div><div>          Arg = N1;</div><div>        }</div><div><br></div><div>        if (CFP) {</div><div>          // 0*x --> 0</div><div>          if (CFP->isZero())</div>
<div>            return CFP;</div><div>          // 1*x --> x</div><div>          if (CFP->isExactlyValue(1.0))</div><div>            return Arg;</div><div>        }</div></div><div><br></div><div>If that doesn't work, your version seems fine.</div>
</div></div>
</blockquote></div><br></div></body></html>