<div dir="ltr">Sure, Chandler. I was running late yesterday, and didn't get a chance to reduce it. <div><br></div><div>Attached is a reduced test. One more thing I found is, to trigger this issue, the base of the GEP mustn't be a GlobalVariable; otherwise, LLVM will go to ConstantFold.cpp:2131 and generate an inbounds GEP ConstantExpr.</div>
<div><br></div><div><div>2127   // If all indices are known integers and normalized, we can do a simple        </div><div>2128   // check for the "inbounds" property.                                          </div>
<div>2129   if (!Unknown && !inBounds &&                                                   </div><div>2130       isa<GlobalVariable>(C) && isInBoundsIndices(Idxs))                         </div>
<div>2131     return ConstantExpr::getInBoundsGetElementPtr(C, Idxs);                      </div></div><div><br></div><div>My attached test is reduced from a CUDA program that declares the global array as __shared__. Therefore, the base of the GEP is an addrspacecast from the global array. <br>
</div><div><br></div><div>One possible fix is to pass IsInBounds to ConstantFoldInstOperands and CastGEPIndices, so that CastGEPIndices can inherit this attribute. Are there better ways? </div><div><br></div><div>Let me know if you need more information. </div>
<div><br></div><div>Jingyue</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Apr 21, 2014 at 8:04 PM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class=""><br><div class="gmail_quote">On Mon, Apr 21, 2014 at 7:59 PM, Jingyue Wu <span dir="ltr"><<a href="mailto:jingyue@google.com" target="_blank">jingyue@google.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I can't upload my program due to confidentiality, but the problem is obvious. </blockquote></div><br></div>A reduced test case would still help, and should go into any fix to ensure we don't regress here...</div>

</div>
</blockquote></div><br></div>