mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-12 13:30:51 +00:00
For PR9500.
--- Merging r128041 into '.': U test/CodeGen/X86/fast-isel-gep.ll U lib/Target/X86/X86FastISel.cpp git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_29@128042 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7520d84941
commit
fcce259185
@ -399,33 +399,39 @@ bool X86FastISel::X86SelectAddress(const Value *V, X86AddressMode &AM) {
|
|||||||
Disp += SL->getElementOffset(Idx);
|
Disp += SL->getElementOffset(Idx);
|
||||||
} else {
|
} else {
|
||||||
uint64_t S = TD.getTypeAllocSize(GTI.getIndexedType());
|
uint64_t S = TD.getTypeAllocSize(GTI.getIndexedType());
|
||||||
SmallVector<const Value *, 4> Worklist;
|
for (;;) {
|
||||||
Worklist.push_back(Op);
|
|
||||||
do {
|
|
||||||
Op = Worklist.pop_back_val();
|
|
||||||
if (const ConstantInt *CI = dyn_cast<ConstantInt>(Op)) {
|
if (const ConstantInt *CI = dyn_cast<ConstantInt>(Op)) {
|
||||||
// Constant-offset addressing.
|
// Constant-offset addressing.
|
||||||
Disp += CI->getSExtValue() * S;
|
Disp += CI->getSExtValue() * S;
|
||||||
} else if (isa<AddOperator>(Op) &&
|
break;
|
||||||
isa<ConstantInt>(cast<AddOperator>(Op)->getOperand(1))) {
|
}
|
||||||
// An add with a constant operand. Fold the constant.
|
if (isa<AddOperator>(Op) &&
|
||||||
|
(!isa<Instruction>(Op) ||
|
||||||
|
FuncInfo.MBBMap[cast<Instruction>(Op)->getParent()]
|
||||||
|
== FuncInfo.MBB) &&
|
||||||
|
isa<ConstantInt>(cast<AddOperator>(Op)->getOperand(1))) {
|
||||||
|
// An add (in the same block) with a constant operand. Fold the
|
||||||
|
// constant.
|
||||||
ConstantInt *CI =
|
ConstantInt *CI =
|
||||||
cast<ConstantInt>(cast<AddOperator>(Op)->getOperand(1));
|
cast<ConstantInt>(cast<AddOperator>(Op)->getOperand(1));
|
||||||
Disp += CI->getSExtValue() * S;
|
Disp += CI->getSExtValue() * S;
|
||||||
// Add the other operand back to the work list.
|
// Iterate on the other operand.
|
||||||
Worklist.push_back(cast<AddOperator>(Op)->getOperand(0));
|
Op = cast<AddOperator>(Op)->getOperand(0);
|
||||||
} else if (IndexReg == 0 &&
|
continue;
|
||||||
(!AM.GV || !Subtarget->isPICStyleRIPRel()) &&
|
}
|
||||||
(S == 1 || S == 2 || S == 4 || S == 8)) {
|
if (IndexReg == 0 &&
|
||||||
|
(!AM.GV || !Subtarget->isPICStyleRIPRel()) &&
|
||||||
|
(S == 1 || S == 2 || S == 4 || S == 8)) {
|
||||||
// Scaled-index addressing.
|
// Scaled-index addressing.
|
||||||
Scale = S;
|
Scale = S;
|
||||||
IndexReg = getRegForGEPIndex(Op).first;
|
IndexReg = getRegForGEPIndex(Op).first;
|
||||||
if (IndexReg == 0)
|
if (IndexReg == 0)
|
||||||
return false;
|
return false;
|
||||||
} else
|
break;
|
||||||
// Unsupported.
|
}
|
||||||
goto unsupported_gep;
|
// Unsupported.
|
||||||
} while (!Worklist.empty());
|
goto unsupported_gep;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check for displacement overflow.
|
// Check for displacement overflow.
|
||||||
|
@ -87,4 +87,23 @@ define i64 @test5(i8* %A, i32 %I, i64 %B) nounwind {
|
|||||||
; X64-NEXT: ret
|
; X64-NEXT: ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; PR9500, rdar://9156159 - Don't do non-local address mode folding,
|
||||||
|
; because it may require values which wouldn't otherwise be live out
|
||||||
|
; of their blocks.
|
||||||
|
define void @test6() {
|
||||||
|
if.end: ; preds = %if.then, %invoke.cont
|
||||||
|
%tmp15 = load i64* undef
|
||||||
|
%dec = add i64 %tmp15, 13
|
||||||
|
store i64 %dec, i64* undef
|
||||||
|
%call17 = invoke i8* @_ZNK18G__FastAllocString4dataEv()
|
||||||
|
to label %invoke.cont16 unwind label %lpad
|
||||||
|
|
||||||
|
invoke.cont16: ; preds = %if.then14
|
||||||
|
%arrayidx18 = getelementptr inbounds i8* %call17, i64 %dec
|
||||||
|
store i8 0, i8* %arrayidx18
|
||||||
|
unreachable
|
||||||
|
|
||||||
|
lpad: ; preds = %if.end19, %if.then14, %if.end, %entry
|
||||||
|
unreachable
|
||||||
|
}
|
||||||
|
declare i8* @_ZNK18G__FastAllocString4dataEv() nounwind
|
||||||
|
Loading…
Reference in New Issue
Block a user