[llvm-branch-commits] [llvm-branch] r128042 - in /llvm/branches/release_29: ./ lib/Target/X86/X86FastISel.cpp test/CodeGen/X86/fast-isel-gep.ll
Bill Wendling
isanbard at gmail.com
Mon Mar 21 17:16:16 PDT 2011
Author: void
Date: Mon Mar 21 19:16:16 2011
New Revision: 128042
URL: http://llvm.org/viewvc/llvm-project?rev=128042&view=rev
Log:
For PR9500.
--- Merging r128041 into '.':
U test/CodeGen/X86/fast-isel-gep.ll
U lib/Target/X86/X86FastISel.cpp
Modified:
llvm/branches/release_29/ (props changed)
llvm/branches/release_29/lib/Target/X86/X86FastISel.cpp
llvm/branches/release_29/test/CodeGen/X86/fast-isel-gep.ll
Propchange: llvm/branches/release_29/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar 21 19:16:16 2011
@@ -1,2 +1,2 @@
/llvm/branches/Apple/Pertwee:110850,110961
-/llvm/trunk:127241,127263-127264,127298,127325,127350-127351,127441,127464,127780
+/llvm/trunk:127241,127263-127264,127298,127325,127350-127351,127441,127464,127780,128041
Modified: llvm/branches/release_29/lib/Target/X86/X86FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_29/lib/Target/X86/X86FastISel.cpp?rev=128042&r1=128041&r2=128042&view=diff
==============================================================================
--- llvm/branches/release_29/lib/Target/X86/X86FastISel.cpp (original)
+++ llvm/branches/release_29/lib/Target/X86/X86FastISel.cpp Mon Mar 21 19:16:16 2011
@@ -399,33 +399,39 @@
Disp += SL->getElementOffset(Idx);
} else {
uint64_t S = TD.getTypeAllocSize(GTI.getIndexedType());
- SmallVector<const Value *, 4> Worklist;
- Worklist.push_back(Op);
- do {
- Op = Worklist.pop_back_val();
+ for (;;) {
if (const ConstantInt *CI = dyn_cast<ConstantInt>(Op)) {
// Constant-offset addressing.
Disp += CI->getSExtValue() * S;
- } else if (isa<AddOperator>(Op) &&
- isa<ConstantInt>(cast<AddOperator>(Op)->getOperand(1))) {
- // An add with a constant operand. Fold the constant.
+ break;
+ }
+ 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 =
cast<ConstantInt>(cast<AddOperator>(Op)->getOperand(1));
Disp += CI->getSExtValue() * S;
- // Add the other operand back to the work list.
- Worklist.push_back(cast<AddOperator>(Op)->getOperand(0));
- } else if (IndexReg == 0 &&
- (!AM.GV || !Subtarget->isPICStyleRIPRel()) &&
- (S == 1 || S == 2 || S == 4 || S == 8)) {
+ // Iterate on the other operand.
+ Op = cast<AddOperator>(Op)->getOperand(0);
+ continue;
+ }
+ if (IndexReg == 0 &&
+ (!AM.GV || !Subtarget->isPICStyleRIPRel()) &&
+ (S == 1 || S == 2 || S == 4 || S == 8)) {
// Scaled-index addressing.
Scale = S;
IndexReg = getRegForGEPIndex(Op).first;
if (IndexReg == 0)
return false;
- } else
- // Unsupported.
- goto unsupported_gep;
- } while (!Worklist.empty());
+ break;
+ }
+ // Unsupported.
+ goto unsupported_gep;
+ }
}
}
// Check for displacement overflow.
Modified: llvm/branches/release_29/test/CodeGen/X86/fast-isel-gep.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_29/test/CodeGen/X86/fast-isel-gep.ll?rev=128042&r1=128041&r2=128042&view=diff
==============================================================================
--- llvm/branches/release_29/test/CodeGen/X86/fast-isel-gep.ll (original)
+++ llvm/branches/release_29/test/CodeGen/X86/fast-isel-gep.ll Mon Mar 21 19:16:16 2011
@@ -87,4 +87,23 @@
; 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
More information about the llvm-branch-commits
mailing list