<p dir="ltr">My answer isn't very authoritative (I work mostly in clang) but this seems like a test that accidentally treated the old buggy behavior. This isn't uncommon (tests are often accidentally over constrained by someone copy pasting the current output as the expected output. It's not uncommon to have to fix up tests like this when fixing a bug)</p>

<div class="gmail_quote">On Jan 23, 2013 1:42 AM, "Sebastien DELDON-GNB" <<a href="mailto:sebastien.deldon@st.com">sebastien.deldon@st.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all,<br>
<br>
This is my first post on this mailing list, so hope I'm doing the right thing. If not sorry about it.<br>
Here is my proposed fix for bug 14986, filed by myself. One problem with this fix is that<br>
getelementptr.ll test reports an error. I think error reported by getelementptr.ll test might not be correct,<br>
here is error I've got:<br>
<br>
/work1/tools/llvm/trunk/sources/test/Transforms/InstCombine/getelementptr.ll:438:10: error: expected string not found in input<br>
; CHECK: ret i8* getelementptr ([11 x i8]* @array, i64 1676976733973595601, i64 4)<br>
         ^<br>
<stdin>:253:19: note: scanning from here<br>
define i8* @test36() nounwind {<br>
                  ^<br>
<stdin>:254:2: note: possible intended match here<br>
 ret i8* getelementptr ([11 x i8]* @array, i64 -1, i64 10)<br>
 ^<br>
--<br>
<br>
Here is my proposed patch.<br>
<br>
Index: ConstantFolding.cpp<br>
===================================================================<br>
--- ConstantFolding.cpp (revision 173137)<br>
+++ ConstantFolding.cpp (working copy)<br>
@@ -736,8 +736,13 @@<br>
       else {<br>
         // The element size is non-zero divide the offset by the element<br>
         // size (rounding down), to compute the index at this level.<br>
-        APInt NewIdx = Offset.udiv(ElemSize);<br>
+        APInt NewIdx = Offset.sdiv(ElemSize);<br>
         Offset -= NewIdx * ElemSize;<br>
+<br>
+        if (Offset.isNegative()) {<br>
+            NewIdx-- ;<br>
+            Offset += ElemSize ;<br>
+        }<br>
         NewIdxs.push_back(ConstantInt::get(IntPtrTy, NewIdx));<br>
       }<br>
       Ty = ATy->getElementType();<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>