Index: llvm/trunk/lib/Transforms/Scalar/ConstantHoisting.cpp =================================================================== --- llvm/trunk/lib/Transforms/Scalar/ConstantHoisting.cpp +++ llvm/trunk/lib/Transforms/Scalar/ConstantHoisting.cpp @@ -245,6 +245,12 @@ // Scan all operands. for (unsigned Idx = 0, E = Inst->getNumOperands(); Idx != E; ++Idx) { + if (Idx != 0 && Idx != E - 1 && dyn_cast(Inst)) { + // skip constant int in GEP as the CodeGenPrepare require at most + // one variable offset. + continue; + } + Value *Opnd = Inst->getOperand(Idx); // Visit constant integers.