bug 122:
authorReid Spencer <rspencer@reidspencer.com>
Sun, 18 Jul 2004 00:38:32 +0000 (00:38 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Sun, 18 Jul 2004 00:38:32 +0000 (00:38 +0000)
- 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

lib/Target/SparcV9/InstrSelection/InstrForest.cpp
lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp
lib/Target/SparcV9/SparcV9InstrInfo.cpp
lib/Target/SparcV9/SparcV9PreSelection.cpp
lib/Target/X86/InstSelectSimple.cpp
lib/Target/X86/Printer.cpp
lib/Target/X86/X86AsmPrinter.cpp
lib/Target/X86/X86ISelSimple.cpp
lib/Target/X86/X86SimpInstrSelector.cpp
lib/Transforms/Scalar/InstructionCombining.cpp

index cc22b3774a1cff8a834b54636c94ce07d05950cc..271857b80adc96ee64756b93d007a451583b3889 100644 (file)
@@ -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);
index e0f43b529bfe596f38c3f8db4809771585492d20..7e0f6c48c6de0a4e537aa0a4cc1f071613222deb 100644 (file)
@@ -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 =
index 986d4a88b3e8651fd40e0509aab483007e9bb23d..30d35546e6cbb5d47449eb9435aa4306ca439621 100644 (file)
@@ -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
index 00cfd1295e6a5f9ce04b41aa88183db65197ea00..fc629a6a3fdb4ced0dffee0dc39bc4847a2eb49d 100644 (file)
@@ -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,
index 06165e9f6e1843d37815837ab590ffcfefd9a004..3dced748bc179e1286fe00446f4bbfbb28488257 100644 (file)
@@ -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.
index 1181e0506be695ad565b375fcd97569805d97d1e..9ac981f2b99b41355b4851be6c69449e930f010e 100644 (file)
@@ -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()) {
index 1181e0506be695ad565b375fcd97569805d97d1e..9ac981f2b99b41355b4851be6c69449e930f010e 100644 (file)
@@ -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()) {
index 06165e9f6e1843d37815837ab590ffcfefd9a004..3dced748bc179e1286fe00446f4bbfbb28488257 100644 (file)
@@ -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.
index 9fd487374d8aba24c44d3f8096f957436368e69c..2ada795718b8233d7ebd5fab684a4c1cb645bc28 100644 (file)
@@ -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);
index 8d353c8063abcaa21af420558d50e8ce24b6b7fe..33370c33977e5271d23c249a68eaaa084d8ef702 100644 (file)
@@ -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;
       }