Skip to content

Commit

Permalink
Revert "[FastISel][AArch64] Add custom lowering for GEPs."
Browse files Browse the repository at this point in the history
This breaks our internal build bots. Reverting it to get the bots green again.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219776 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
ributzka committed Oct 15, 2014
1 parent 75d77cd commit 0081070
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 105 deletions.
85 changes: 0 additions & 85 deletions lib/Target/AArch64/AArch64FastISel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ class AArch64FastISel final : public FastISel {
bool selectBitCast(const Instruction *I);
bool selectFRem(const Instruction *I);
bool selectSDiv(const Instruction *I);
bool selectGetElementPtr(const Instruction *I);

// Utility helper routines.
bool isTypeLegal(Type *Ty, MVT &VT);
Expand Down Expand Up @@ -4542,88 +4541,6 @@ bool AArch64FastISel::selectSDiv(const Instruction *I) {
return true;
}

bool AArch64FastISel::selectGetElementPtr(const Instruction *I) {
unsigned N = getRegForValue(I->getOperand(0));
if (!N)
return false;
bool NIsKill = hasTrivialKill(I->getOperand(0));

// Keep a running tab of the total offset to coalesce multiple N = N + Offset
// into a single N = N + TotalOffset.
uint64_t TotalOffs = 0;
Type *Ty = I->getOperand(0)->getType();
MVT VT = TLI.getPointerTy();
for (auto OI = std::next(I->op_begin()), E = I->op_end(); OI != E; ++OI) {
const Value *Idx = *OI;
if (auto *StTy = dyn_cast<StructType>(Ty)) {
unsigned Field = cast<ConstantInt>(Idx)->getZExtValue();
// N = N + Offset
if (Field)
TotalOffs += DL.getStructLayout(StTy)->getElementOffset(Field);
Ty = StTy->getElementType(Field);
} else {
Ty = cast<SequentialType>(Ty)->getElementType();
// If this is a constant subscript, handle it quickly.
if (const auto *CI = dyn_cast<ConstantInt>(Idx)) {
if (CI->isZero())
continue;
// N = N + Offset
TotalOffs +=
DL.getTypeAllocSize(Ty) * cast<ConstantInt>(CI)->getSExtValue();
continue;
}
if (TotalOffs) {
N = emitAddSub_ri(/*UseAdd=*/true, VT, N, NIsKill, TotalOffs);
if (!N) {
unsigned C = fastEmit_i(VT, VT, ISD::Constant, TotalOffs);
if (!C)
return false;
N = emitAddSub_rr(/*UseAdd=*/true, VT, N, NIsKill, C, true);
if (!N)
return false;
}
NIsKill = true;
TotalOffs = 0;
}

// N = N + Idx * ElementSize;
uint64_t ElementSize = DL.getTypeAllocSize(Ty);
std::pair<unsigned, bool> Pair = getRegForGEPIndex(Idx);
unsigned IdxN = Pair.first;
bool IdxNIsKill = Pair.second;
if (!IdxN)
return false;

if (ElementSize != 1) {
unsigned C = fastEmit_i(VT, VT, ISD::Constant, ElementSize);
if (!C)
return false;
IdxN = emitMul_rr(VT, IdxN, IdxNIsKill, C, true);
if (!IdxN)
return false;
IdxNIsKill = true;
}
N = fastEmit_rr(VT, VT, ISD::ADD, N, NIsKill, IdxN, IdxNIsKill);
if (!N)
return false;
}
}
if (TotalOffs) {
N = emitAddSub_ri(/*UseAdd=*/true, VT, N, NIsKill, TotalOffs);
if (!N) {
unsigned C = fastEmit_i(VT, VT, ISD::Constant, TotalOffs);
if (!C)
return false;
N = emitAddSub_rr(/*UseAdd=*/true, VT, N, NIsKill, C, true);
if (!N)
return false;
}
}

updateValueMap(I, N);
return true;
}

bool AArch64FastISel::fastSelectInstruction(const Instruction *I) {
switch (I->getOpcode()) {
default:
Expand Down Expand Up @@ -4695,8 +4612,6 @@ bool AArch64FastISel::fastSelectInstruction(const Instruction *I) {
return selectRet(I);
case Instruction::FRem:
return selectFRem(I);
case Instruction::GetElementPtr:
return selectGetElementPtr(I);
}

// fall-back to target-independent instruction selection.
Expand Down
5 changes: 3 additions & 2 deletions test/CodeGen/AArch64/arm64-fast-isel-alloca.ll
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ define void @main() nounwind {
entry:
; CHECK: main
; CHECK: mov x29, sp
; CHECK: mov [[REG:x[0-9]+]], sp
; CHECK-NEXT: add x0, [[REG]], #8
; CHECK: mov x[[REG:[0-9]+]], sp
; CHECK-NEXT: orr x[[REG1:[0-9]+]], xzr, #0x8
; CHECK-NEXT: add x0, x[[REG]], x[[REG1]]
%E = alloca %struct.S2Ty, align 4
%B = getelementptr inbounds %struct.S2Ty* %E, i32 0, i32 1
call void @takeS1(%struct.S1Ty* %B)
Expand Down
18 changes: 0 additions & 18 deletions test/CodeGen/AArch64/fast-isel-gep.ll

This file was deleted.

0 comments on commit 0081070

Please sign in to comment.