<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Jun 18, 2016 at 11:14 PM, David Majnemer via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: majnemer<br>
Date: Sun Jun 19 01:14:56 2016<br>
New Revision: 273105<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=273105&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=273105&view=rev</a><br>
Log:<br>
[LoadCombine] Combine Loads formed from GEPS with negative indexes<br>
<br>
Change the underlying offset and comparisons to use int64_t instead of<br>
uint64_t.<br>
<br>
Patch by River Riddle!<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D21499" rel="noreferrer" target="_blank">http://reviews.llvm.org/D21499</a><br>
<br>
Added:<br>
llvm/trunk/test/Transforms/LoadCombine/load-combine-negativegep.ll<br>
Modified:<br>
llvm/trunk/lib/Transforms/Scalar/LoadCombine.cpp<br>
<br>
Modified: llvm/trunk/lib/Transforms/Scalar/LoadCombine.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoadCombine.cpp?rev=273105&r1=273104&r2=273105&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoadCombine.cpp?rev=273105&r1=273104&r2=273105&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/Scalar/LoadCombine.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Scalar/LoadCombine.cpp Sun Jun 19 01:14:56 2016<br>
@@ -40,7 +40,7 @@ STATISTIC(NumLoadsCombined, "Number of l<br>
namespace {<br>
struct PointerOffsetPair {<br>
Value *Pointer;<br>
- uint64_t Offset;<br>
+ int64_t Offset;<br>
};<br>
<br>
struct LoadPOPPair {<br>
@@ -102,7 +102,7 @@ PointerOffsetPair LoadCombine::getPointe<br>
unsigned BitWidth = DL.getPointerTypeSizeInBits(GEP->getType());<br>
APInt Offset(BitWidth, 0);<br>
if (GEP->accumulateConstantOffset(DL, Offset))<br>
- POP.Offset += Offset.getZExtValue();<br>
+ POP.Offset += Offset.getSExtValue();<br></blockquote><div><br></div><div>This line seems a bit suspcious... one, it assumes pointers are never more than 64 bits wide, and two, the addition could have signed overflow.<br></div><div><br></div><div>-Eli<br></div></div></div></div>