[llvm-commits] [llvm] r81162 - /llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
Dan Gohman
gohman at apple.com
Mon Sep 7 15:34:44 PDT 2009
Author: djg
Date: Mon Sep 7 17:34:43 2009
New Revision: 81162
URL: http://llvm.org/viewvc/llvm-project?rev=81162&view=rev
Log:
Preserve the InBounds flag when evaluating a getelementptr instruction
into a getelementptr ConstantExpr.
Modified:
llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=81162&r1=81161&r2=81162&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Mon Sep 7 17:34:43 2009
@@ -2227,8 +2227,9 @@
for (User::op_iterator i = GEP->op_begin() + 1, e = GEP->op_end();
i != e; ++i)
GEPOps.push_back(getVal(Values, *i));
- InstResult =
- ConstantExpr::getGetElementPtr(P, &GEPOps[0], GEPOps.size());
+ InstResult = cast<GEPOperator>(GEP)->isInBounds() ?
+ ConstantExpr::getInBoundsGetElementPtr(P, &GEPOps[0], GEPOps.size()) :
+ ConstantExpr::getGetElementPtr(P, &GEPOps[0], GEPOps.size());
} else if (LoadInst *LI = dyn_cast<LoadInst>(CurInst)) {
if (LI->isVolatile()) return false; // no volatile accesses.
InstResult = ComputeLoadResult(getVal(Values, LI->getOperand(0)),
More information about the llvm-commits
mailing list