diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2004-07-18 00:38:32 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2004-07-18 00:38:32 +0000 |
commit | 8863f1814ba2c26910edb30857d10a8587f2f7de (patch) | |
tree | e6c4d8c224ba03635f233ecb2710963a48a4bd9d /lib | |
parent | 2786542aad27f4456e551cd4ee744be6b6ae41ba (diff) | |
download | external_llvm-8863f1814ba2c26910edb30857d10a8587f2f7de.zip external_llvm-8863f1814ba2c26910edb30857d10a8587f2f7de.tar.gz external_llvm-8863f1814ba2c26910edb30857d10a8587f2f7de.tar.bz2 |
bug 122:
- Replace ConstantPointerRef usage with GlobalValue usage
- Minimize redundant isa<GlobalValue> usage
- Correct isa<Constant> for GlobalValue subclass
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14950 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/SparcV9/InstrSelection/InstrForest.cpp | 10 | ||||
-rw-r--r-- | lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp | 19 | ||||
-rw-r--r-- | lib/Target/SparcV9/SparcV9InstrInfo.cpp | 26 | ||||
-rw-r--r-- | lib/Target/SparcV9/SparcV9PreSelection.cpp | 2 | ||||
-rw-r--r-- | lib/Target/X86/InstSelectSimple.cpp | 17 | ||||
-rw-r--r-- | lib/Target/X86/Printer.cpp | 4 | ||||
-rw-r--r-- | lib/Target/X86/X86AsmPrinter.cpp | 4 | ||||
-rw-r--r-- | lib/Target/X86/X86ISelSimple.cpp | 17 | ||||
-rw-r--r-- | lib/Target/X86/X86SimpInstrSelector.cpp | 19 | ||||
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 29 |
10 files changed, 56 insertions, 91 deletions
diff --git a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp index cc22b37..271857b 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp @@ -244,8 +244,7 @@ InstructionNode* InstrForest::buildTreeForInstruction(Instruction *instr) { && !instr->isTerminator(); if (includeAddressOperand || isa<Instruction>(operand) || - isa<Constant>(operand) || isa<Argument>(operand) || - isa<GlobalVariable>(operand)) + isa<Constant>(operand) || isa<Argument>(operand)) { // This operand is a data value @@ -273,8 +272,11 @@ InstructionNode* InstrForest::buildTreeForInstruction(Instruction *instr) { // Recursively create a treeNode for it. opTreeNode = buildTreeForInstruction((Instruction*)operand); } else if (Constant *CPV = dyn_cast<Constant>(operand)) { - // Create a leaf node for a constant - opTreeNode = new ConstantNode(CPV); + if (isa<GlobalValue>(CPV)) + opTreeNode = new VRegNode(operand); + else + // Create a leaf node for a constant + opTreeNode = new ConstantNode(CPV); } else { // Create a leaf node for the virtual register opTreeNode = new VRegNode(operand); diff --git a/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp index e0f43b5..7e0f6c4 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp @@ -22,6 +22,7 @@ #include "llvm/Constants.h" #include "llvm/BasicBlock.h" #include "llvm/DerivedTypes.h" +#include "llvm/GlobalValue.h" #include "../SparcV9InstrSelectionSupport.h" namespace llvm { @@ -159,13 +160,14 @@ FixConstantOperandsForInstr(Instruction* vmInstr, if (mop.getType() == MachineOperand::MO_VirtualRegister) { assert(mop.getVRegValue() != NULL); opValue = mop.getVRegValue(); - if (Constant *opConst = dyn_cast<Constant>(opValue)) { - opType = ChooseRegOrImmed(opConst, opCode, target, - (immedPos == (int)op), machineRegNum, - immedValue); - if (opType == MachineOperand::MO_VirtualRegister) - constantThatMustBeLoaded = true; - } + if (Constant *opConst = dyn_cast<Constant>(opValue)) + if (!isa<GlobalValue>(opConst)) { + opType = ChooseRegOrImmed(opConst, opCode, target, + (immedPos == (int)op), machineRegNum, + immedValue); + if (opType == MachineOperand::MO_VirtualRegister) + constantThatMustBeLoaded = true; + } } else { // // If the operand is from the constant pool, don't try to change it. @@ -242,8 +244,7 @@ FixConstantOperandsForInstr(Instruction* vmInstr, argDesc = CallArgsDescriptor::get(minstr); for (unsigned i=0, N=minstr->getNumImplicitRefs(); i < N; ++i) - if (isa<Constant>(minstr->getImplicitRef(i)) || - isa<GlobalValue>(minstr->getImplicitRef(i))) + if (isa<Constant>(minstr->getImplicitRef(i))) { Value* oldVal = minstr->getImplicitRef(i); TmpInstruction* tmpReg = diff --git a/lib/Target/SparcV9/SparcV9InstrInfo.cpp b/lib/Target/SparcV9/SparcV9InstrInfo.cpp index 986d4a8..30d3554 100644 --- a/lib/Target/SparcV9/SparcV9InstrInfo.cpp +++ b/lib/Target/SparcV9/SparcV9InstrInfo.cpp @@ -56,16 +56,14 @@ SparcV9InstrInfo::ConvertConstantToIntType(const TargetMachine &target, if (! destType->isIntegral() && ! isa<PointerType>(destType)) return C; - if (! isa<Constant>(V)) + if (! isa<Constant>(V) || isa<GlobalValue>(V)) return C; - // ConstantPointerRef: no conversions needed: get value and return it - if (const ConstantPointerRef* CPR = dyn_cast<ConstantPointerRef>(V)) { - // A ConstantPointerRef is just a reference to GlobalValue. + // GlobalValue: no conversions needed: get value and return it + if (const GlobalValue* GV = dyn_cast<GlobalValue>(V)) { isValidConstant = true; // may be overwritten by recursive call - return (CPR->isNullValue()? 0 - : ConvertConstantToIntType(target, CPR->getValue(), destType, - isValidConstant)); + return GV->isNullValue() ? 0 : + ConvertConstantToIntType(target, GV, destType, isValidConstant); } // ConstantBool: no conversions needed: get value and return it @@ -284,7 +282,7 @@ CreateSETXLabel(const TargetMachine& target, Value* val, Instruction* tmpReg, Instruction* dest, std::vector<MachineInstr*>& mvec) { - assert(isa<Constant>(val) || isa<GlobalValue>(val) && + assert(isa<Constant>(val) && "I only know about constant values and global addresses"); MachineInstr* MI; @@ -467,7 +465,7 @@ SparcV9InstrInfo::CreateCodeToLoadConst(const TargetMachine& target, std::vector<MachineInstr*>& mvec, MachineCodeForInstruction& mcfi) const { - assert(isa<Constant>(val) || isa<GlobalValue>(val) && + assert(isa<Constant>(val) && "I only know about constant values and global addresses"); // Use a "set" instruction for known constants or symbolic constants (labels) @@ -477,10 +475,6 @@ SparcV9InstrInfo::CreateCodeToLoadConst(const TargetMachine& target, // const Type* valType = val->getType(); - // A ConstantPointerRef is just a reference to GlobalValue. - while (isa<ConstantPointerRef>(val)) - val = cast<ConstantPointerRef>(val)->getValue(); - if (isa<GlobalValue>(val)) { TmpInstruction* tmpReg = new TmpInstruction(mcfi, PointerType::get(val->getType()), val); @@ -688,7 +682,9 @@ SparcV9InstrInfo::CreateCopyInstructionsByType(const TargetMachine& target, // a global variable (i.e., a constant address), generate a load // instruction instead of an add // - if (isa<Constant>(src)) { + if (isa<GlobalValue>(src)) + loadConstantToReg = true; + else if (isa<Constant>(src)) { unsigned int machineRegNum; int64_t immedValue; MachineOperand::MachineOperandType opType = @@ -698,8 +694,6 @@ SparcV9InstrInfo::CreateCopyInstructionsByType(const TargetMachine& target, if (opType == MachineOperand::MO_VirtualRegister) loadConstantToReg = true; } - else if (isa<GlobalValue>(src)) - loadConstantToReg = true; if (loadConstantToReg) { // `src' is constant and cannot fit in immed field for the ADD diff --git a/lib/Target/SparcV9/SparcV9PreSelection.cpp b/lib/Target/SparcV9/SparcV9PreSelection.cpp index 00cfd12..fc629a6 100644 --- a/lib/Target/SparcV9/SparcV9PreSelection.cpp +++ b/lib/Target/SparcV9/SparcV9PreSelection.cpp @@ -85,8 +85,6 @@ namespace { // getGlobalAddr(): Put address of a global into a v. register. static GetElementPtrInst* getGlobalAddr(Value* ptr, Instruction& insertBefore) { - if (isa<ConstantPointerRef>(ptr)) - ptr = cast<ConstantPointerRef>(ptr)->getValue(); return (isa<GlobalVariable>(ptr)) ? new GetElementPtrInst(ptr, diff --git a/lib/Target/X86/InstSelectSimple.cpp b/lib/Target/X86/InstSelectSimple.cpp index 06165e9..3dced74 100644 --- a/lib/Target/X86/InstSelectSimple.cpp +++ b/lib/Target/X86/InstSelectSimple.cpp @@ -394,16 +394,10 @@ unsigned ISel::getReg(Value *V, MachineBasicBlock *MBB, MachineBasicBlock::iterator IPt) { // If this operand is a constant, emit the code to copy the constant into // the register here... - // if (Constant *C = dyn_cast<Constant>(V)) { unsigned Reg = makeAnotherReg(V->getType()); copyConstantToRegister(MBB, IPt, C, Reg); return Reg; - } else if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) { - unsigned Reg = makeAnotherReg(V->getType()); - // Move the address of the global into the register - BuildMI(*MBB, IPt, X86::MOV32ri, 1, Reg).addGlobalAddress(GV); - return Reg; } else if (CastInst *CI = dyn_cast<CastInst>(V)) { // Do not emit noop casts at all, unless it's a double -> float cast. if (getClassB(CI->getType()) == getClassB(CI->getOperand(0)->getType()) && @@ -554,8 +548,8 @@ void ISel::copyConstantToRegister(MachineBasicBlock *MBB, } else if (isa<ConstantPointerNull>(C)) { // Copy zero (null pointer) to the register. BuildMI(*MBB, IP, X86::MOV32ri, 1, R).addImm(0); - } else if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(C)) { - BuildMI(*MBB, IP, X86::MOV32ri, 1, R).addGlobalAddress(CPR->getValue()); + } else if (GlobalValue *GV = dyn_cast<GlobalValue>(C)) { + BuildMI(*MBB, IP, X86::MOV32ri, 1, R).addGlobalAddress(GV); } else { std::cerr << "Offending constant: " << *C << "\n"; assert(0 && "Type not handled yet!"); @@ -688,8 +682,7 @@ void ISel::SelectPHINodes() { // If this is a constant or GlobalValue, we may have to insert code // into the basic block to compute it into a virtual register. - if ((isa<Constant>(Val) && !isa<ConstantExpr>(Val)) || - isa<GlobalValue>(Val)) { + if ((isa<Constant>(Val) && !isa<ConstantExpr>(Val))) { // Simple constants get emitted at the end of the basic block, // before any terminator instructions. We "know" that the code to // move a constant into a register will never clobber any flags. @@ -3635,8 +3628,6 @@ bool ISel::isGEPFoldable(MachineBasicBlock *MBB, Value *Src, User::op_iterator IdxBegin, User::op_iterator IdxEnd, unsigned &BaseReg, unsigned &Scale, unsigned &IndexReg, unsigned &Disp) { - if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Src)) - Src = CPR->getValue(); std::vector<Value*> GEPOps; GEPOps.resize(IdxEnd-IdxBegin+1); @@ -3660,8 +3651,6 @@ void ISel::emitGEPOperation(MachineBasicBlock *MBB, Value *Src, User::op_iterator IdxBegin, User::op_iterator IdxEnd, unsigned TargetReg) { const TargetData &TD = TM.getTargetData(); - if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Src)) - Src = CPR->getValue(); // If this is a getelementptr null, with all constant integer indices, just // replace it with TargetReg = 42. diff --git a/lib/Target/X86/Printer.cpp b/lib/Target/X86/Printer.cpp index 1181e05..9ac981f 100644 --- a/lib/Target/X86/Printer.cpp +++ b/lib/Target/X86/Printer.cpp @@ -178,10 +178,10 @@ void Printer::emitConstantValueOnly(const Constant *CV) { O << (unsigned long long)CI->getValue(); else if (const ConstantUInt *CI = dyn_cast<ConstantUInt>(CV)) O << CI->getValue(); - else if (const ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(CV)) + else if (const GlobalValue *GV = dyn_cast<GlobalValue>(CV)) // This is a constant address for a global variable or function. Use the // name of the variable or function as the address value. - O << Mang->getValueName(CPR->getValue()); + O << Mang->getValueName(GV); else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) { const TargetData &TD = TM.getTargetData(); switch(CE->getOpcode()) { diff --git a/lib/Target/X86/X86AsmPrinter.cpp b/lib/Target/X86/X86AsmPrinter.cpp index 1181e05..9ac981f 100644 --- a/lib/Target/X86/X86AsmPrinter.cpp +++ b/lib/Target/X86/X86AsmPrinter.cpp @@ -178,10 +178,10 @@ void Printer::emitConstantValueOnly(const Constant *CV) { O << (unsigned long long)CI->getValue(); else if (const ConstantUInt *CI = dyn_cast<ConstantUInt>(CV)) O << CI->getValue(); - else if (const ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(CV)) + else if (const GlobalValue *GV = dyn_cast<GlobalValue>(CV)) // This is a constant address for a global variable or function. Use the // name of the variable or function as the address value. - O << Mang->getValueName(CPR->getValue()); + O << Mang->getValueName(GV); else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) { const TargetData &TD = TM.getTargetData(); switch(CE->getOpcode()) { diff --git a/lib/Target/X86/X86ISelSimple.cpp b/lib/Target/X86/X86ISelSimple.cpp index 06165e9..3dced74 100644 --- a/lib/Target/X86/X86ISelSimple.cpp +++ b/lib/Target/X86/X86ISelSimple.cpp @@ -394,16 +394,10 @@ unsigned ISel::getReg(Value *V, MachineBasicBlock *MBB, MachineBasicBlock::iterator IPt) { // If this operand is a constant, emit the code to copy the constant into // the register here... - // if (Constant *C = dyn_cast<Constant>(V)) { unsigned Reg = makeAnotherReg(V->getType()); copyConstantToRegister(MBB, IPt, C, Reg); return Reg; - } else if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) { - unsigned Reg = makeAnotherReg(V->getType()); - // Move the address of the global into the register - BuildMI(*MBB, IPt, X86::MOV32ri, 1, Reg).addGlobalAddress(GV); - return Reg; } else if (CastInst *CI = dyn_cast<CastInst>(V)) { // Do not emit noop casts at all, unless it's a double -> float cast. if (getClassB(CI->getType()) == getClassB(CI->getOperand(0)->getType()) && @@ -554,8 +548,8 @@ void ISel::copyConstantToRegister(MachineBasicBlock *MBB, } else if (isa<ConstantPointerNull>(C)) { // Copy zero (null pointer) to the register. BuildMI(*MBB, IP, X86::MOV32ri, 1, R).addImm(0); - } else if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(C)) { - BuildMI(*MBB, IP, X86::MOV32ri, 1, R).addGlobalAddress(CPR->getValue()); + } else if (GlobalValue *GV = dyn_cast<GlobalValue>(C)) { + BuildMI(*MBB, IP, X86::MOV32ri, 1, R).addGlobalAddress(GV); } else { std::cerr << "Offending constant: " << *C << "\n"; assert(0 && "Type not handled yet!"); @@ -688,8 +682,7 @@ void ISel::SelectPHINodes() { // If this is a constant or GlobalValue, we may have to insert code // into the basic block to compute it into a virtual register. - if ((isa<Constant>(Val) && !isa<ConstantExpr>(Val)) || - isa<GlobalValue>(Val)) { + if ((isa<Constant>(Val) && !isa<ConstantExpr>(Val))) { // Simple constants get emitted at the end of the basic block, // before any terminator instructions. We "know" that the code to // move a constant into a register will never clobber any flags. @@ -3635,8 +3628,6 @@ bool ISel::isGEPFoldable(MachineBasicBlock *MBB, Value *Src, User::op_iterator IdxBegin, User::op_iterator IdxEnd, unsigned &BaseReg, unsigned &Scale, unsigned &IndexReg, unsigned &Disp) { - if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Src)) - Src = CPR->getValue(); std::vector<Value*> GEPOps; GEPOps.resize(IdxEnd-IdxBegin+1); @@ -3660,8 +3651,6 @@ void ISel::emitGEPOperation(MachineBasicBlock *MBB, Value *Src, User::op_iterator IdxBegin, User::op_iterator IdxEnd, unsigned TargetReg) { const TargetData &TD = TM.getTargetData(); - if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Src)) - Src = CPR->getValue(); // If this is a getelementptr null, with all constant integer indices, just // replace it with TargetReg = 42. diff --git a/lib/Target/X86/X86SimpInstrSelector.cpp b/lib/Target/X86/X86SimpInstrSelector.cpp index 9fd4873..2ada795 100644 --- a/lib/Target/X86/X86SimpInstrSelector.cpp +++ b/lib/Target/X86/X86SimpInstrSelector.cpp @@ -316,13 +316,13 @@ namespace { // If this operand is a constant, emit the code to copy the constant into // the register here... // - if (Constant *C = dyn_cast<Constant>(V)) { - copyConstantToRegister(MBB, IPt, C, Reg); - RegMap.erase(V); // Assign a new name to this constant if ref'd again - } else if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) { + if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) { // Move the address of the global into the register BuildMI(*MBB, IPt, X86::MOV32ri, 1, Reg).addGlobalAddress(GV); RegMap.erase(V); // Assign a new name to this address if ref'd again + } else if (Constant *C = dyn_cast<Constant>(V)) { + copyConstantToRegister(MBB, IPt, C, Reg); + RegMap.erase(V); // Assign a new name to this constant if ref'd again } return Reg; @@ -480,8 +480,8 @@ void ISel::copyConstantToRegister(MachineBasicBlock *MBB, } else if (isa<ConstantPointerNull>(C)) { // Copy zero (null pointer) to the register. BuildMI(*MBB, IP, X86::MOV32ri, 1, R).addImm(0); - } else if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(C)) { - BuildMI(*MBB, IP, X86::MOV32ri, 1, R).addGlobalAddress(CPR->getValue()); + } else if (GlobalValue *GV = dyn_cast<GlobalValue>(C)) { + BuildMI(*MBB, IP, X86::MOV32ri, 1, R).addGlobalAddress(GV); } else { std::cerr << "Offending constant: " << *C << "\n"; assert(0 && "Type not handled yet!"); @@ -602,7 +602,7 @@ void ISel::SelectPHINodes() { // If this is a constant or GlobalValue, we may have to insert code // into the basic block to compute it into a virtual register. - if (isa<Constant>(Val) || isa<GlobalValue>(Val)) { + if (isa<Constant>(Val)) { // Because we don't want to clobber any values which might be in // physical registers with the computation of this constant (which // might be arbitrarily complex if it is a constant expression), @@ -2589,9 +2589,6 @@ bool ISel::isGEPFoldable(MachineBasicBlock *MBB, Value *Src, User::op_iterator IdxBegin, User::op_iterator IdxEnd, unsigned &BaseReg, unsigned &Scale, unsigned &IndexReg, unsigned &Disp) { - if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Src)) - Src = CPR->getValue(); - std::vector<Value*> GEPOps; GEPOps.resize(IdxEnd-IdxBegin+1); GEPOps[0] = Src; @@ -2614,8 +2611,6 @@ void ISel::emitGEPOperation(MachineBasicBlock *MBB, Value *Src, User::op_iterator IdxBegin, User::op_iterator IdxEnd, unsigned TargetReg) { const TargetData &TD = TM.getTargetData(); - if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Src)) - Src = CPR->getValue(); std::vector<Value*> GEPOps; GEPOps.resize(IdxEnd-IdxBegin+1); diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 8d353c80..33370c3 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -2457,11 +2457,10 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { if (!isa<ConstantExpr>(CS.getCalledValue())) return false; ConstantExpr *CE = cast<ConstantExpr>(CS.getCalledValue()); if (CE->getOpcode() != Instruction::Cast || - !isa<ConstantPointerRef>(CE->getOperand(0))) + !isa<GlobalValue>(CE->getOperand(0))) return false; - ConstantPointerRef *CPR = cast<ConstantPointerRef>(CE->getOperand(0)); - if (!isa<Function>(CPR->getValue())) return false; - Function *Callee = cast<Function>(CPR->getValue()); + if (!isa<Function>(CE->getOperand(0))) return false; + Function *Callee = cast<Function>(CE->getOperand(0)); Instruction *Caller = CS.getInstruction(); // Okay, this is a cast from a function to a different type. Unless doing so @@ -2811,7 +2810,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { if (I == E) { // If they are all constants... Constant *CE = - ConstantExpr::getGetElementPtr(ConstantPointerRef::get(GV), Indices); + ConstantExpr::getGetElementPtr(GV, Indices); // Replace all uses of the GEP with the new constexpr... return ReplaceInstUsesWith(GEP, CE); @@ -2978,8 +2977,8 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) { if (Constant *C = dyn_cast<Constant>(Op)) if (C->isNullValue()) // load null -> 0 return ReplaceInstUsesWith(LI, Constant::getNullValue(LI.getType())); - else if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(C)) - Op = CPR->getValue(); + else if (isa<GlobalValue>(C)) + Op = C; // Instcombine load (constant global) into the value loaded... if (GlobalVariable *GV = dyn_cast<GlobalVariable>(Op)) @@ -2989,11 +2988,10 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) { // Instcombine load (constantexpr_GEP global, 0, ...) into the value loaded... if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Op)) if (CE->getOpcode() == Instruction::GetElementPtr) { - if (ConstantPointerRef *G=dyn_cast<ConstantPointerRef>(CE->getOperand(0))) - if (GlobalVariable *GV = dyn_cast<GlobalVariable>(G->getValue())) - if (GV->isConstant() && !GV->isExternal()) - if (Constant *V = GetGEPGlobalInitializer(GV->getInitializer(), CE)) - return ReplaceInstUsesWith(LI, V); + if (GlobalVariable *GV = dyn_cast<GlobalVariable>(CE->getOperand(0))) + if (GV->isConstant() && !GV->isExternal()) + if (Constant *V = GetGEPGlobalInitializer(GV->getInitializer(), CE)) + return ReplaceInstUsesWith(LI, V); } else if (CE->getOpcode() == Instruction::Cast) { if (Instruction *Res = InstCombineLoadCast(*this, LI)) return Res; @@ -3106,12 +3104,11 @@ bool InstCombiner::runOnFunction(Function &F) { } // Check to see if any of the operands of this instruction are a - // ConstantPointerRef. Since they sneak in all over the place and inhibit + // GlobalValue. Since they sneak in all over the place and inhibit // optimization, we want to strip them out unconditionally! for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) - if (ConstantPointerRef *CPR = - dyn_cast<ConstantPointerRef>(I->getOperand(i))) { - I->setOperand(i, CPR->getValue()); + if (isa<GlobalValue>(I->getOperand(i))) { + I->setOperand(i, I->getOperand(i)); Changed = true; } |