[llvm-commits] [llvm-gcc-4.2] r78757 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Dan Gohman
gohman at apple.com
Tue Aug 11 17:35:32 PDT 2009
Author: djg
Date: Tue Aug 11 19:35:31 2009
New Revision: 78757
URL: http://llvm.org/viewvc/llvm-project?rev=78757&view=rev
Log:
Use the inbounds variant of getelementptr for common pointer arithmetic.
Modified:
llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=78757&r1=78756&r2=78757&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Aug 11 19:35:31 2009
@@ -3663,7 +3663,9 @@
if (Opc == Instruction::Sub)
EltOffset = -EltOffset;
Constant *C = ConstantInt::get(Type::Int64Ty, EltOffset);
- Value *V = Builder.CreateGEP(LHS, C);
+ Value *V = flag_wrapv ?
+ Builder.CreateGEP(LHS, C) :
+ Builder.CreateInBoundsGEP(LHS, C);
return BitCastToType(V, ConvertType(TREE_TYPE(exp)));
}
}
@@ -6694,7 +6696,9 @@
if (TREE_CODE(ArrayTreeType) == ARRAY_TYPE)
Idx.push_back(ConstantInt::get(IntPtrTy, 0));
Idx.push_back(IndexVal);
- Value *Ptr = Builder.CreateGEP(ArrayAddr, Idx.begin(), Idx.end());
+ Value *Ptr = flag_wrapv ?
+ Builder.CreateGEP(ArrayAddr, Idx.begin(), Idx.end()) :
+ Builder.CreateInBoundsGEP(ArrayAddr, Idx.begin(), Idx.end());
const Type *ElementTy = ConvertType(ElementType);
unsigned Alignment = MinAlign(ArrayAlign, TD.getABITypeAlignment(ElementTy));
@@ -6719,7 +6723,9 @@
if (isa<ConstantInt>(IndexVal))
Alignment = MinAlign(ArrayAlign,
cast<ConstantInt>(IndexVal)->getZExtValue());
- Value *Ptr = Builder.CreateGEP(ArrayAddr, IndexVal);
+ Value *Ptr = flag_wrapv ?
+ Builder.CreateGEP(ArrayAddr, IndexVal) :
+ Builder.CreateInBoundsGEP(ArrayAddr, IndexVal);
return LValue(BitCastToType(Ptr,
PointerType::getUnqual(ConvertType(TREE_TYPE(exp)))),
Alignment);
More information about the llvm-commits
mailing list