<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; "><br><div><div>On Aug 21, 2012, at 1:43 AM, Chandler Carruth <<a href="mailto:chandlerc@gmail.com">chandlerc@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_extra"><div class="gmail_quote">On Mon, Aug 20, 2012 at 9:48 AM, Chris Lattner <span dir="ltr"><<a href="mailto:clattner@apple.com" target="_blank" class="cremed">clattner@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 class="im"><br>
On Aug 20, 2012, at 2:27 AM, Chandler Carruth <<a href="mailto:chandlerc@gmail.com" class="cremed">chandlerc@gmail.com</a>> wrote:<br>
<br>
> Hello,<br>
><br>
> I've been hacking on SROA a lot (email coming up on that front..) and one of the oddities is that SROA is doing a very instcombine-like optimization. I was able to move it over to InstCombine w/o touching any other aspect of SROA. It simplifies the model of SROA a bit, and also the optimization works much better in the instcombine framework: this is about nuking one instruction, and replacing it with another.<br>

<br>
</div>Makes sense to me.</blockquote><div><br></div><div>Thanks, r162271.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Can pointsToConstantGlobal be simplified with Value::stripInBoundsOffsets ?<br>
</blockquote><div><br></div><div>It's not clear to me that this would be an improvement... pointsToConstantGlobal get's to cheat pretty spectacularly by only ever handling constant expressions. It's also pretty simple. Any particular reason to write it using the more general value stripping? We'd still have almost as much code in order to assert that it was still a constant expression.</div></div></div></blockquote><br></div><div>I was thinking that you replace this:</div><div><br></div><div>+static bool pointsToConstantGlobal(Value *V) {<br>+  if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V))<br>+    return GV->isConstant();<br>+  if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))<br>+    if (CE->getOpcode() == Instruction::BitCast ||<br>+        CE->getOpcode() == Instruction::GetElementPtr)<br>+      return pointsToConstantGlobal(CE->getOperand(0));<br>+  return false;<br>+}<br></div><div><br></div><div>with this:</div><div><br></div><div>static bool pointsToConstantGlobal(Value *V) {</div><div>   if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V->stripInBoundsOffsets()))</div><div>     return GV->isConstant();<br>  return false;<br>}<br></div><br><div>which is then inlined into its only caller.</div><div><br></div><div>-Chris</div></body></html>