* Fix a GlobalAddress lowering bug.
* Teach DAG combiner about X86ISD::SETCC by adding a TargetLowering hook.

llvm-svn: 24921
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 61d3aee..456a254 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -122,6 +122,7 @@
     setOperationAction(ISD::SETCC          , MVT::i8   , Custom);
     setOperationAction(ISD::SETCC          , MVT::i16  , Custom);
     setOperationAction(ISD::SETCC          , MVT::i32  , Custom);
+    setOperationAction(ISD::GlobalAddress  , MVT::i32  , Custom);
   }
 
   // We don't have line number support yet.
@@ -1051,6 +1052,7 @@
   }
   case ISD::GlobalAddress:
     GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal();
+    SDOperand GVOp = DAG.getTargetGlobalAddress(GV, getPointerTy());
     // For Darwin, external and weak symbols are indirect, so we want to load
     // the value at address GV, not the value of GV itself.  This means that
     // the GlobalAddress must be in the base or index register of the address,
@@ -1058,10 +1060,10 @@
     if (getTargetMachine().
         getSubtarget<X86Subtarget>().getIndirectExternAndWeakGlobals() &&
         (GV->hasWeakLinkage() || GV->isExternal()))
-      return DAG.getLoad(MVT::i32, DAG.getEntryNode(), Op,
-                         DAG.getSrcValue(NULL));
+      return DAG.getLoad(MVT::i32, DAG.getEntryNode(),
+                         GVOp, DAG.getSrcValue(NULL));
     else
-      return Op;
+      return GVOp;
     break;
   }
 }
@@ -1086,3 +1088,18 @@
   case X86ISD::RET_FLAG:           return "X86ISD::RET_FLAG";
   }
 }
+
+bool X86TargetLowering::isMaskedValueZeroForTargetNode(const SDOperand &Op,
+                                                       uint64_t Mask) const {
+
+  unsigned Opc = Op.getOpcode();
+
+  switch (Opc) {
+  default:
+    assert(Opc >= ISD::BUILTIN_OP_END && "Expected a target specific node");
+    break;
+  case X86ISD::SETCC: return (Mask & 1) == 0;
+  }
+
+  return false;
+}