From 487c9ff80216fcf06aafa5b4ace56c7be125cf06 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Wed, 10 Dec 2008 21:49:05 +0000 Subject: [PATCH] Some code clean up. llvm-svn: 60850 --- lib/Target/X86/X86ISelDAGToDAG.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/Target/X86/X86ISelDAGToDAG.cpp b/lib/Target/X86/X86ISelDAGToDAG.cpp index e6c344890dc..34e4544e836 100644 --- a/lib/Target/X86/X86ISelDAGToDAG.cpp +++ b/lib/Target/X86/X86ISelDAGToDAG.cpp @@ -1532,22 +1532,24 @@ SDNode *X86DAGToDAGISel::Select(SDValue N) { SDValue Chain = Node->getOperand(0); SDValue N1 = Node->getOperand(1); SDValue N2 = Node->getOperand(2); - if (!isa(N1)) + FrameIndexSDNode *FINode = dyn_cast(N1); + if (!FINode) break; - int FI = cast(N1)->getIndex(); if (N2.getOpcode() == ISD::ADD && N2.getOperand(0).getOpcode() == X86ISD::GlobalBaseReg) N2 = N2.getOperand(1); - if (N2.getOpcode() == X86ISD::Wrapper && - isa(N2.getOperand(0))) { - GlobalValue *GV = - cast(N2.getOperand(0))->getGlobal(); - SDValue Tmp1 = CurDAG->getTargetFrameIndex(FI, TLI.getPointerTy()); - SDValue Tmp2 = CurDAG->getTargetGlobalAddress(GV, TLI.getPointerTy()); - SDValue Ops[] = { Tmp1, Tmp2, Chain }; - return CurDAG->getTargetNode(TargetInstrInfo::DECLARE, - MVT::Other, Ops, 3); - } + if (N2.getOpcode() != X86ISD::Wrapper) + break; + GlobalAddressSDNode *GVNode = dyn_cast(N2.getOperand(0)); + if (!GVNode) + break; + SDValue Tmp1 = CurDAG->getTargetFrameIndex(FINode->getIndex(), + TLI.getPointerTy()); + SDValue Tmp2 = CurDAG->getTargetGlobalAddress(GVNode->getGlobal(), + TLI.getPointerTy()); + SDValue Ops[] = { Tmp1, Tmp2, Chain }; + return CurDAG->getTargetNode(TargetInstrInfo::DECLARE, + MVT::Other, Ops, 3); break; } }