<div dir="ltr">On Fri, Aug 16, 2013 at 6:16 PM, Matt Arsenault <span dir="ltr"><<a href="mailto:arsenm2@gmail.com" target="_blank">arsenm2@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div class="h5"><br><div><div>On Aug 16, 2013, at 17:51 , Eli Friedman <<a href="mailto:eli.friedman@gmail.com" target="_blank">eli.friedman@gmail.com</a>> wrote:</div>
<br><blockquote type="cite"><div dir="ltr">On Fri, Aug 16, 2013 at 5:21 PM, Matt Arsenault <span dir="ltr"><<a href="mailto:Matthew.Arsenault@amd.com" target="_blank">Matthew.Arsenault@amd.com</a>></span> wrote:<br>
<div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Also fix it calculating the wrong value. The struct index is not a ConstantInt, so it was being interpreted as an array index.<br>


<br>
<a href="http://llvm-reviews.chandlerc.com/D1431" target="_blank">http://llvm-reviews.chandlerc.com/D1431</a><br>
<br>
Files:<br>
  include/llvm/Transforms/Utils/Local.h<br>
  lib/Analysis/ValueTracking.cpp<br>
  test/Transforms/InstCombine/getelementptr.ll<br>
<br>
Index: include/llvm/Transforms/Utils/Local.h<br>
===================================================================<br>
--- include/llvm/Transforms/Utils/Local.h<br>
+++ include/llvm/Transforms/Utils/Local.h<br>
@@ -203,12 +203,17 @@<br>
        ++i, ++GTI) {<br>
     Value *Op = *i;<br>
     uint64_t Size = TD.getTypeAllocSize(GTI.getIndexedType()) & PtrSizeMask;<br>
-    if (ConstantInt *OpC = dyn_cast<ConstantInt>(Op)) {<br>
-      if (OpC->isZero()) continue;<br>
+    if (Constant *OpC = dyn_cast<Constant>(Op)) {<br>
+      if (OpC->isZeroValue())<br>
+        continue;<br>
+<br>
+      if (OpC->getType()->isVectorTy())<br>
+        OpC = OpC->getSplatValue();<br><br></blockquote><div>What if getSplatValue() returns null?</div></div></div></div></blockquote><br></div></div></div><div>It isn't allowed to have a vector struct index with different valued elements, so this should always work</div>
<br></div></blockquote><div><br></div><div>The getSplatValue() call is before the check for whether the type refers to a struct...</div><div><br></div><div>-Eli </div></div><br></div></div>