forked from OSchip/llvm-project
Type of first GEP operand is always the same as the target pointer type.
llvm-svn: 55097
This commit is contained in:
parent
7b3932e5d8
commit
4b5c038cd0
|
@ -56,9 +56,7 @@ bool FastISel::SelectGetElementPtr(Instruction *I,
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const Type *Ty = I->getOperand(0)->getType();
|
const Type *Ty = I->getOperand(0)->getType();
|
||||||
MVT VT = MVT::getMVT(Ty, /*HandleUnknown=*/true);
|
MVT VT = MVT::getMVT(Ty, /*HandleUnknown=*/false);
|
||||||
MVT::SimpleValueType PtrVT = TLI.getPointerTy().getSimpleVT();
|
|
||||||
|
|
||||||
for (GetElementPtrInst::op_iterator OI = I->op_begin()+1, E = I->op_end();
|
for (GetElementPtrInst::op_iterator OI = I->op_begin()+1, E = I->op_end();
|
||||||
OI != E; ++OI) {
|
OI != E; ++OI) {
|
||||||
Value *Idx = *OI;
|
Value *Idx = *OI;
|
||||||
|
@ -69,7 +67,7 @@ bool FastISel::SelectGetElementPtr(Instruction *I,
|
||||||
uint64_t Offs = TD.getStructLayout(StTy)->getElementOffset(Field);
|
uint64_t Offs = TD.getStructLayout(StTy)->getElementOffset(Field);
|
||||||
// FIXME: This can be optimized by combining the add with a
|
// FIXME: This can be optimized by combining the add with a
|
||||||
// subsequent one.
|
// subsequent one.
|
||||||
N = FastEmit_ri(VT.getSimpleVT(), ISD::ADD, N, Offs, PtrVT);
|
N = FastEmit_ri(VT.getSimpleVT(), ISD::ADD, N, Offs, VT.getSimpleVT());
|
||||||
if (N == 0)
|
if (N == 0)
|
||||||
// Unhandled operand. Halt "fast" selection and bail.
|
// Unhandled operand. Halt "fast" selection and bail.
|
||||||
return false;
|
return false;
|
||||||
|
@ -83,7 +81,7 @@ bool FastISel::SelectGetElementPtr(Instruction *I,
|
||||||
if (CI->getZExtValue() == 0) continue;
|
if (CI->getZExtValue() == 0) continue;
|
||||||
uint64_t Offs =
|
uint64_t Offs =
|
||||||
TD.getABITypeSize(Ty)*cast<ConstantInt>(CI)->getSExtValue();
|
TD.getABITypeSize(Ty)*cast<ConstantInt>(CI)->getSExtValue();
|
||||||
N = FastEmit_ri(VT.getSimpleVT(), ISD::ADD, N, Offs, PtrVT);
|
N = FastEmit_ri(VT.getSimpleVT(), ISD::ADD, N, Offs, VT.getSimpleVT());
|
||||||
if (N == 0)
|
if (N == 0)
|
||||||
// Unhandled operand. Halt "fast" selection and bail.
|
// Unhandled operand. Halt "fast" selection and bail.
|
||||||
return false;
|
return false;
|
||||||
|
@ -99,7 +97,7 @@ bool FastISel::SelectGetElementPtr(Instruction *I,
|
||||||
|
|
||||||
// If the index is smaller or larger than intptr_t, truncate or extend
|
// If the index is smaller or larger than intptr_t, truncate or extend
|
||||||
// it.
|
// it.
|
||||||
MVT IdxVT = MVT::getMVT(Idx->getType(), /*HandleUnknown=*/true);
|
MVT IdxVT = MVT::getMVT(Idx->getType(), /*HandleUnknown=*/false);
|
||||||
if (IdxVT.bitsLT(VT))
|
if (IdxVT.bitsLT(VT))
|
||||||
IdxN = FastEmit_r(VT.getSimpleVT(), ISD::SIGN_EXTEND, IdxN);
|
IdxN = FastEmit_r(VT.getSimpleVT(), ISD::SIGN_EXTEND, IdxN);
|
||||||
else if (IdxVT.bitsGT(VT))
|
else if (IdxVT.bitsGT(VT))
|
||||||
|
@ -111,7 +109,7 @@ bool FastISel::SelectGetElementPtr(Instruction *I,
|
||||||
// FIXME: If multiple is power of two, turn it into a shift. The
|
// FIXME: If multiple is power of two, turn it into a shift. The
|
||||||
// optimization should be in FastEmit_ri?
|
// optimization should be in FastEmit_ri?
|
||||||
IdxN = FastEmit_ri(VT.getSimpleVT(), ISD::MUL, IdxN,
|
IdxN = FastEmit_ri(VT.getSimpleVT(), ISD::MUL, IdxN,
|
||||||
ElementSize, PtrVT);
|
ElementSize, VT.getSimpleVT());
|
||||||
if (IdxN == 0)
|
if (IdxN == 0)
|
||||||
// Unhandled operand. Halt "fast" selection and bail.
|
// Unhandled operand. Halt "fast" selection and bail.
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue