<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Oct 29, 2010, at 9:50 PM, Nick Lewycky wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; "><div style="word-wrap: break-word; "><div><div>Also, the way it is used is confusing.  Why not name it "getSplatElement" and have it return null on failure?</div></div></div></blockquote><div><br></div><div>Because I want to preserve the pattern of a declaring a single variable inside an if-statement with a dyn_cast. I'm planning to find and update code which currently does that with a test for ConstantInt/FP and don't want to add lots of this pattern:</div><div><br></div><div>  Value *V = value;</div><div>  if (ConstantVector *CV = dyn_cast<ConstantVector>(V))</div><div>    if (Constant *Splat = CV->getSplatValue())</div><div>      V = Splat;</div><div>  if (ConstantInt *CI = dyn_cast<ConstantInt>(V)) {</div><div>    ...</div><div><br></div><div>all over. If getSplatElement() returned NULL instead of "this" then I would only be able to remove one line of that (the test for ConstantVector).</div><div><br></div><div>I guess I don't really understand what makes the replacement code confusing.</div></span></blockquote></div><br><div>Well, the function currently only has one client, so it's hard to tell what other places use it and what would be more convenient.  I'm just saying that the API is cleaner and easier to understand if it returns null on a non-splat value.  I'm fine with keeping it your way if you strongly prefer that.</div><div><br></div><div>-Chris</div></body></html>