[llvm] r193111 - Fix CodeGen for different size address space GEPs
Matt Arsenault
Matthew.Arsenault at amd.com
Mon Oct 21 13:03:54 PDT 2013
Author: arsenm
Date: Mon Oct 21 15:03:54 2013
New Revision: 193111
URL: http://llvm.org/viewvc/llvm-project?rev=193111&view=rev
Log:
Fix CodeGen for different size address space GEPs
Added:
llvm/trunk/test/CodeGen/R600/gep-address-space.ll
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=193111&r1=193110&r2=193111&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Mon Oct 21 15:03:54 2013
@@ -1513,7 +1513,7 @@ static const MCExpr *lowerConstant(const
case Instruction::GetElementPtr: {
const DataLayout &DL = *AP.TM.getDataLayout();
// Generate a symbolic expression for the byte address
- APInt OffsetAI(DL.getPointerSizeInBits(), 0);
+ APInt OffsetAI(DL.getPointerTypeSizeInBits(CE->getType()), 0);
cast<GEPOperator>(CE)->accumulateConstantOffset(DL, OffsetAI);
const MCExpr *Base = lowerConstant(CE->getOperand(0), AP);
@@ -1539,7 +1539,7 @@ static const MCExpr *lowerConstant(const
// Handle casts to pointers by changing them into casts to the appropriate
// integer type. This promotes constant folding and simplifies this code.
Constant *Op = CE->getOperand(0);
- Op = ConstantExpr::getIntegerCast(Op, DL.getIntPtrType(CV->getContext()),
+ Op = ConstantExpr::getIntegerCast(Op, DL.getIntPtrType(CV->getType()),
false/*ZExt*/);
return lowerConstant(Op, AP);
}
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=193111&r1=193110&r2=193111&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Mon Oct 21 15:03:54 2013
@@ -3229,10 +3229,12 @@ void SelectionDAGBuilder::visitExtractVa
}
void SelectionDAGBuilder::visitGetElementPtr(const User &I) {
- SDValue N = getValue(I.getOperand(0));
+ Value *Op0 = I.getOperand(0);
// Note that the pointer operand may be a vector of pointers. Take the scalar
// element which holds a pointer.
- Type *Ty = I.getOperand(0)->getType()->getScalarType();
+ Type *Ty = Op0->getType()->getScalarType();
+ unsigned AS = Ty->getPointerAddressSpace();
+ SDValue N = getValue(Op0);
for (GetElementPtrInst::const_op_iterator OI = I.op_begin()+1, E = I.op_end();
OI != E; ++OI) {
@@ -3248,10 +3250,6 @@ void SelectionDAGBuilder::visitGetElemen
Ty = StTy->getElementType(Field);
} else {
- uint32_t AS = 0;
- if (PointerType *PtrType = dyn_cast<PointerType>(Ty)) {
- AS = PtrType->getAddressSpace();
- }
Ty = cast<SequentialType>(Ty)->getElementType();
// If this is a constant subscript, handle it quickly.
Added: llvm/trunk/test/CodeGen/R600/gep-address-space.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/R600/gep-address-space.ll?rev=193111&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/R600/gep-address-space.ll (added)
+++ llvm/trunk/test/CodeGen/R600/gep-address-space.ll Mon Oct 21 15:03:54 2013
@@ -0,0 +1,10 @@
+; RUN: llc -march=r600 -mcpu=SI < %s | FileCheck %s
+
+define void @use_gep_address_space([1024 x i32] addrspace(3)* %array) nounwind {
+; CHECK-LABEL @use_gep_address_space:
+; CHECK: ADD_I32
+ %p = getelementptr [1024 x i32] addrspace(3)* %array, i16 0, i16 16
+ store i32 99, i32 addrspace(3)* %p
+ ret void
+}
+
More information about the llvm-commits
mailing list