LLVM API Documentation

AlphaGenDAGISel.inc

Go to the documentation of this file.
00001 //===- TableGen'erated file -------------------------------------*- C++ -*-===//
00002 //
00003 // DAG Instruction Selector for the Alpha target
00004 //
00005 // Automatically generated file, do not edit!
00006 //
00007 //===----------------------------------------------------------------------===//
00008 
00009 // *** NOTE: This file is #included into the middle of the target
00010 // *** instruction selector class.  These functions are really methods.
00011 
00012 // Instance var to keep track of multiply used nodes that have 
00013 // already been selected.
00014 std::map<SDOperand, SDOperand> CodeGenMap;
00015 // Instance var to keep track of mapping of chain generating nodes
00016 // and their place handle nodes.
00017 std::map<SDOperand, SDOperand> HandleMap;
00018 // Instance var to keep track of mapping of place handle nodes
00019 // and their replacement nodes.
00020 std::map<SDOperand, SDOperand> ReplaceMap;
00021 
00022 static void findNonImmUse(SDNode* Use, SDNode* Def, bool &found, std::set<SDNode *> &Visited) {
00023   if (found || !Visited.insert(Use).second) return;
00024   for (unsigned i = 0, e = Use->getNumOperands(); i != e; ++i) {
00025     SDNode *N = Use->getOperand(i).Val;
00026     if (N->getNodeDepth() >= Def->getNodeDepth()) {
00027       if (N != Def) {
00028         findNonImmUse(N, Def, found, Visited);
00029       } else {
00030         found = true;
00031         break;
00032       }
00033     }
00034   }
00035 }
00036 
00037 static bool isNonImmUse(SDNode* Use, SDNode* Def) {
00038   std::set<SDNode *> Visited;
00039   bool found = false;
00040   for (unsigned i = 0, e = Use->getNumOperands(); i != e; ++i) {
00041     SDNode *N = Use->getOperand(i).Val;
00042     if (N != Def) {
00043       findNonImmUse(N, Def, found, Visited);
00044       if (found) break;
00045     }
00046   }
00047   return found;
00048 }
00049 
00050 // AddHandleReplacement - Note the pending replacement node for a
00051 // handle node in ReplaceMap.
00052 void AddHandleReplacement(SDNode *H, unsigned HNum, SDNode *R, unsigned RNum) {
00053   SDOperand N(H, HNum);
00054   std::map<SDOperand, SDOperand>::iterator HMI = HandleMap.find(N);
00055   if (HMI != HandleMap.end()) {
00056     ReplaceMap[HMI->second] = SDOperand(R, RNum);
00057     HandleMap.erase(N);
00058   }
00059 }
00060 
00061 // SelectDanglingHandles - Select replacements for all `dangling`
00062 // handles.Some handles do not yet have replacements because the
00063 // nodes they replacements have only dead readers.
00064 void SelectDanglingHandles() {
00065   for (std::map<SDOperand, SDOperand>::iterator I = HandleMap.begin(),
00066          E = HandleMap.end(); I != E; ++I) {
00067     SDOperand N = I->first;
00068     SDOperand R;
00069     Select(R, N.getValue(0));
00070     AddHandleReplacement(N.Val, N.ResNo, R.Val, R.ResNo);
00071   }
00072 }
00073 
00074 // ReplaceHandles - Replace all the handles with the real target
00075 // specific nodes.
00076 void ReplaceHandles() {
00077   for (std::map<SDOperand, SDOperand>::iterator I = ReplaceMap.begin(),
00078         E = ReplaceMap.end(); I != E; ++I) {
00079     SDOperand From = I->first;
00080     SDOperand To   = I->second;
00081     for (SDNode::use_iterator UI = From.Val->use_begin(), E = From.Val->use_end(); UI != E; ++UI) {
00082       SDNode *Use = *UI;
00083       std::vector<SDOperand> Ops;
00084       for (unsigned i = 0, e = Use->getNumOperands(); i != e; ++i) {
00085         SDOperand O = Use->getOperand(i);
00086         if (O.Val == From.Val)
00087           Ops.push_back(To);
00088         else
00089           Ops.push_back(O);
00090       }
00091       SDOperand U = SDOperand(Use, 0);
00092       CurDAG->UpdateNodeOperands(U, Ops);
00093     }
00094   }
00095 }
00096 
00097 // UpdateFoldedChain - return a SDOperand of the new chain created
00098 // if the folding were to happen. This is called when, for example,
00099 // a load is folded into a store. If the store's chain is the load,
00100 // then the resulting node's input chain would be the load's input
00101 // chain. If the store's chain is a TokenFactor and the load's
00102 // output chain feeds into in, then the new chain is a TokenFactor
00103 // with the other operands along with the input chain of the load.
00104 SDOperand UpdateFoldedChain(SelectionDAG *DAG, SDNode *N, SDNode *Chain, SDNode* &OldTF) {
00105   OldTF = NULL;
00106   if (N == Chain) {
00107     return N->getOperand(0);
00108   } else if (Chain->getOpcode() == ISD::TokenFactor &&
00109              N->isOperand(Chain)) {
00110     SDOperand Ch = SDOperand(Chain, 0);
00111     std::map<SDOperand, SDOperand>::iterator CGMI = CodeGenMap.find(Ch);
00112     if (CGMI != CodeGenMap.end())
00113       return SDOperand(0, 0);
00114     OldTF = Chain;
00115     std::vector<SDOperand> Ops;
00116     for (unsigned i = 0; i < Chain->getNumOperands(); ++i) {
00117       SDOperand Op = Chain->getOperand(i);
00118       if (Op.Val == N)
00119         Ops.push_back(N->getOperand(0));
00120       else
00121         Ops.push_back(Op);
00122     }
00123     return DAG->getNode(ISD::TokenFactor, MVT::Other, Ops);
00124   }
00125   return SDOperand(0, 0);
00126 }
00127 
00128 // SelectRoot - Top level entry to DAG isel.
00129 SDOperand SelectRoot(SDOperand N) {
00130   SDOperand ResNode;
00131   Select(ResNode, N);
00132   SelectDanglingHandles();
00133   ReplaceHandles();
00134   ReplaceMap.clear();
00135   return ResNode;
00136 }
00137 
00138 // Node transformations.
00139 inline SDOperand Transform_negX(SDNode *inN) {
00140   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00141  //negate
00142   return getI64Imm(~N->getValue() + 1);
00143 
00144 }
00145 inline SDOperand Transform_nearP2X(SDNode *inN) {
00146   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00147 
00148   return getI64Imm(Log2_64(getNearPower2((uint64_t)N->getValue())));
00149 
00150 }
00151 inline SDOperand Transform_nearP2RemX(SDNode *inN) {
00152   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00153 
00154   uint64_t x = abs(N->getValue() - getNearPower2((uint64_t)N->getValue()));
00155   return getI64Imm(Log2_64(x));
00156 
00157 }
00158 inline SDOperand Transform_invX(SDNode *inN) {
00159   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00160  //invert
00161   return getI64Imm(~N->getValue());
00162 
00163 }
00164 inline SDOperand Transform_iZAPX(SDNode *inN) {
00165   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00166  // get imm to ZAPi
00167   return getI64Imm(get_zapImm((uint64_t)N->getValue()));
00168 
00169 }
00170 inline SDOperand Transform_SExt32(SDNode *inN) {
00171   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00172  //signed extend int to long
00173   return getI64Imm(((int64_t)N->getValue() << 32) >> 32);
00174 
00175 }
00176 inline SDOperand Transform_SExt16(SDNode *inN) {
00177   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00178  //signed extend int to long
00179   return getI64Imm(((int64_t)N->getValue() << 48) >> 48);
00180 
00181 }
00182 inline SDOperand Transform_LL16(SDNode *inN) {
00183   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00184  //lda part of constant
00185   return getI64Imm(get_lda16(N->getValue()));
00186 
00187 }
00188 inline SDOperand Transform_LH16(SDNode *inN) {
00189   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00190  //ldah part of constant (or more if too big)
00191   return getI64Imm(get_ldah16(N->getValue()));
00192 
00193 }
00194 
00195 // Predicate functions.
00196 inline bool Predicate_immAllOnes(SDNode *inN) {
00197   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00198  return N->isAllOnesValue(); 
00199 }
00200 inline bool Predicate_immAllOnesV(SDNode *N) {
00201 
00202   return ISD::isBuildVectorAllOnes(N);
00203 
00204 }
00205 inline bool Predicate_immAllZerosV(SDNode *N) {
00206 
00207   return ISD::isBuildVectorAllZeros(N);
00208 
00209 }
00210 inline bool Predicate_immConst2Part(SDNode *inN) {
00211   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00212 
00213   //true if imm fits in a LDAH LDA pair
00214   int64_t val = (int64_t)N->getValue();
00215   return (val <= IMM_FULLHIGH  && val >= IMM_FULLLOW);
00216 
00217 }
00218 inline bool Predicate_immConst2PartInt(SDNode *inN) {
00219   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00220 
00221   //true if imm fits in a LDAH LDA pair with zeroext
00222   uint64_t uval = N->getValue();
00223   int32_t val32 = (int32_t)uval;
00224   return ((uval >> 32) == 0 && //empty upper bits
00225           val32 <= IMM_FULLHIGH);
00226 //          val32 >= IMM_FULLLOW  + IMM_LOW  * IMM_MULT); //Always True
00227 
00228 }
00229 inline bool Predicate_immFPZ(SDNode *inN) {
00230   ConstantFPSDNode *N = cast<ConstantFPSDNode>(inN);
00231  //the only fpconstant nodes are +/- 0.0
00232   return true;
00233 
00234 }
00235 inline bool Predicate_immRem1(SDNode *inN) {
00236   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00237 
00238   return N->getValue() - getNearPower2((uint64_t)N->getValue()) == 1;
00239 
00240 }
00241 inline bool Predicate_immRem1n(SDNode *inN) {
00242   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00243 
00244   return getNearPower2((uint64_t)N->getValue()) - N->getValue() == 1;
00245 
00246 }
00247 inline bool Predicate_immRem3(SDNode *inN) {
00248   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00249 
00250   return N->getValue() - getNearPower2((uint64_t)N->getValue()) == 3;
00251 
00252 }
00253 inline bool Predicate_immRem3n(SDNode *inN) {
00254   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00255 
00256   return getNearPower2((uint64_t)N->getValue()) - N->getValue() == 3;
00257 
00258 }
00259 inline bool Predicate_immRem4(SDNode *inN) {
00260   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00261 
00262   return N->getValue() - getNearPower2((uint64_t)N->getValue()) == 4;
00263 
00264 }
00265 inline bool Predicate_immRem4n(SDNode *inN) {
00266   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00267 
00268   return getNearPower2((uint64_t)N->getValue()) - N->getValue() == 4;
00269 
00270 }
00271 inline bool Predicate_immRem5(SDNode *inN) {
00272   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00273 
00274   return N->getValue() - getNearPower2((uint64_t)N->getValue()) == 5;
00275 
00276 }
00277 inline bool Predicate_immRem5n(SDNode *inN) {
00278   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00279 
00280   return getNearPower2((uint64_t)N->getValue()) - N->getValue() == 5;
00281 
00282 }
00283 inline bool Predicate_immRemP2(SDNode *inN) {
00284   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00285 
00286   return isPowerOf2_64(N->getValue() - getNearPower2((uint64_t)N->getValue()));
00287 
00288 }
00289 inline bool Predicate_immRemP2n(SDNode *inN) {
00290   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00291 
00292   return isPowerOf2_64(getNearPower2((uint64_t)N->getValue()) - N->getValue());
00293 
00294 }
00295 inline bool Predicate_immSExt16(SDNode *inN) {
00296   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00297  //imm fits in 16 bit sign extended field
00298   return ((int64_t)N->getValue() << 48) >> 48 == (int64_t)N->getValue();
00299 
00300 }
00301 inline bool Predicate_immSExt16int(SDNode *inN) {
00302   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00303  //(int)imm fits in a 16 bit sign extended field
00304   return ((int64_t)N->getValue() << 48) >> 48 == ((int64_t)N->getValue() << 32) >> 32;
00305 
00306 }
00307 inline bool Predicate_immUExt8(SDNode *inN) {
00308   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00309  //imm fits in 8 bit zero extended field
00310   return (uint64_t)N->getValue() == (uint8_t)N->getValue();
00311 
00312 }
00313 inline bool Predicate_immUExt8ME(SDNode *inN) {
00314   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00315  //use this imm for mulqi
00316   int64_t d =  abs((int64_t)N->getValue() - (int64_t)getNearPower2((uint64_t)N->getValue()));
00317   if (isPowerOf2_64(d)) return false;
00318   switch (d) {
00319     case 1: case 3: case 5: return false; 
00320     default: return (uint64_t)N->getValue() == (uint8_t)N->getValue();
00321   };
00322 
00323 }
00324 inline bool Predicate_immUExt8inv(SDNode *inN) {
00325   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00326  //inverted imm fits in 8 bit zero extended field
00327   return (uint64_t)~N->getValue() == (uint8_t)~N->getValue();
00328 
00329 }
00330 inline bool Predicate_immUExt8neg(SDNode *inN) {
00331   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00332  //negated imm fits in 8 bit zero extended field
00333   return ((uint64_t)~N->getValue() + 1) == (uint8_t)((uint64_t)~N->getValue() + 1);
00334 
00335 }
00336 inline bool Predicate_immZAP(SDNode *inN) {
00337   ConstantSDNode *N = cast<ConstantSDNode>(inN);
00338  //imm is good for zapi
00339   uint64_t build = get_zapImm((uint64_t)N->getValue());
00340   return build != 0;
00341 
00342 }
00343 inline bool Predicate_vtFP(SDNode *inN) {
00344   VTSDNode *N = cast<VTSDNode>(inN);
00345  return MVT::isFloatingPoint(N->getVT()); 
00346 }
00347 inline bool Predicate_vtInt(SDNode *inN) {
00348   VTSDNode *N = cast<VTSDNode>(inN);
00349  return MVT::isInteger(N->getVT()); 
00350 }
00351 
00352 
00353 void Select_Alpha_cvtqs(SDOperand &Result, SDOperand N) {
00354   SDOperand N0(0, 0);
00355   SDOperand Tmp0(0, 0);
00356   SDNode *ResNode;
00357   N0 = N.getOperand(0);
00358   if (N.Val->getValueType(0) == MVT::f32 &&
00359       N0.Val->getValueType(0) == MVT::f64) {
00360     Select(Tmp0, N0);
00361     if (N.Val->hasOneUse()) {
00362       Result = CurDAG->SelectNodeTo(N.Val, Alpha::CVTQS, MVT::f32, Tmp0);
00363     } else {
00364       ResNode = CurDAG->getTargetNode(Alpha::CVTQS, MVT::f32, Tmp0);
00365       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00366       Result = SDOperand(ResNode, 0);
00367     }
00368     return;
00369   }
00370   std::cerr << "Cannot yet select: ";
00371   N.Val->dump(CurDAG);
00372   std::cerr << '\n';
00373   abort();
00374 }
00375 
00376 void Select_Alpha_cvtqt(SDOperand &Result, SDOperand N) {
00377   SDOperand N0(0, 0);
00378   SDOperand Tmp0(0, 0);
00379   SDNode *ResNode;
00380   N0 = N.getOperand(0);
00381   if (N.Val->getValueType(0) == MVT::f64 &&
00382       N0.Val->getValueType(0) == MVT::f64) {
00383     Select(Tmp0, N0);
00384     if (N.Val->hasOneUse()) {
00385       Result = CurDAG->SelectNodeTo(N.Val, Alpha::CVTQT, MVT::f64, Tmp0);
00386     } else {
00387       ResNode = CurDAG->getTargetNode(Alpha::CVTQT, MVT::f64, Tmp0);
00388       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00389       Result = SDOperand(ResNode, 0);
00390     }
00391     return;
00392   }
00393   std::cerr << "Cannot yet select: ";
00394   N.Val->dump(CurDAG);
00395   std::cerr << '\n';
00396   abort();
00397 }
00398 
00399 void Select_Alpha_cvttq(SDOperand &Result, SDOperand N) {
00400   SDOperand N0(0, 0);
00401   SDOperand Tmp0(0, 0);
00402   SDNode *ResNode;
00403   N0 = N.getOperand(0);
00404   if (N.Val->getValueType(0) == MVT::f64) {
00405     Select(Tmp0, N0);
00406     if (N.Val->hasOneUse()) {
00407       Result = CurDAG->SelectNodeTo(N.Val, Alpha::CVTTQ, MVT::f64, Tmp0);
00408     } else {
00409       ResNode = CurDAG->getTargetNode(Alpha::CVTTQ, MVT::f64, Tmp0);
00410       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00411       Result = SDOperand(ResNode, 0);
00412     }
00413     return;
00414   }
00415   std::cerr << "Cannot yet select: ";
00416   N.Val->dump(CurDAG);
00417   std::cerr << '\n';
00418   abort();
00419 }
00420 
00421 void Select_Alpha_ftoit(SDOperand &Result, SDOperand N) {
00422   SDOperand N0(0, 0);
00423   SDOperand Tmp0(0, 0);
00424   SDNode *ResNode;
00425   N0 = N.getOperand(0);
00426   if (N0.Val->getValueType(0) == MVT::f64) {
00427     Select(Tmp0, N0);
00428     if (N.Val->hasOneUse()) {
00429       Result = CurDAG->SelectNodeTo(N.Val, Alpha::FTOIT, MVT::i64, Tmp0);
00430     } else {
00431       ResNode = CurDAG->getTargetNode(Alpha::FTOIT, MVT::i64, Tmp0);
00432       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00433       Result = SDOperand(ResNode, 0);
00434     }
00435     return;
00436   }
00437   std::cerr << "Cannot yet select: ";
00438   N.Val->dump(CurDAG);
00439   std::cerr << '\n';
00440   abort();
00441 }
00442 
00443 void Select_Alpha_gprelhi(SDOperand &Result, SDOperand N) {
00444   SDOperand N0(0, 0);
00445   SDOperand N1(0, 0);
00446   SDOperand Tmp0(0, 0);
00447   SDOperand Tmp1(0, 0);
00448   SDNode *ResNode;
00449   N0 = N.getOperand(0);
00450 
00451   // Pattern: (Alpha_gprelhi:i64 (tglobaladdr:i64):$DISP, GPRC:i64:$RB)
00452   // Emits: (LDAHr:i64 (tglobaladdr:i64):$DISP, GPRC:i64:$RB)
00453   // Pattern complexity = 4  cost = 1
00454   if (N0.getOpcode() == ISD::TargetGlobalAddress) {
00455     N1 = N.getOperand(1);
00456     Tmp0 = N0;
00457     Select(Tmp1, N1);
00458     if (N.Val->hasOneUse()) {
00459       Result = CurDAG->SelectNodeTo(N.Val, Alpha::LDAHr, MVT::i64, Tmp0, Tmp1);
00460     } else {
00461       ResNode = CurDAG->getTargetNode(Alpha::LDAHr, MVT::i64, Tmp0, Tmp1);
00462       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00463       Result = SDOperand(ResNode, 0);
00464     }
00465     return;
00466   }
00467 
00468   // Pattern: (Alpha_gprelhi:i64 (tconstpool:i64):$DISP, GPRC:i64:$RB)
00469   // Emits: (LDAHr:i64 (tconstpool:i64):$DISP, GPRC:i64:$RB)
00470   // Pattern complexity = 4  cost = 1
00471   if (N0.getOpcode() == ISD::TargetConstantPool) {
00472     N1 = N.getOperand(1);
00473     Tmp0 = N0;
00474     Select(Tmp1, N1);
00475     if (N.Val->hasOneUse()) {
00476       Result = CurDAG->SelectNodeTo(N.Val, Alpha::LDAHr, MVT::i64, Tmp0, Tmp1);
00477     } else {
00478       ResNode = CurDAG->getTargetNode(Alpha::LDAHr, MVT::i64, Tmp0, Tmp1);
00479       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00480       Result = SDOperand(ResNode, 0);
00481     }
00482     return;
00483   }
00484   std::cerr << "Cannot yet select: ";
00485   N.Val->dump(CurDAG);
00486   std::cerr << '\n';
00487   abort();
00488 }
00489 
00490 void Select_Alpha_gprello(SDOperand &Result, SDOperand N) {
00491   SDOperand N0(0, 0);
00492   SDOperand N1(0, 0);
00493   SDOperand Tmp0(0, 0);
00494   SDOperand Tmp1(0, 0);
00495   SDNode *ResNode;
00496   N0 = N.getOperand(0);
00497 
00498   // Pattern: (Alpha_gprello:i64 (tglobaladdr:i64):$DISP, GPRC:i64:$RB)
00499   // Emits: (LDAr:i64 (tglobaladdr:i64):$DISP, GPRC:i64:$RB)
00500   // Pattern complexity = 4  cost = 1
00501   if (N0.getOpcode() == ISD::TargetGlobalAddress) {
00502     N1 = N.getOperand(1);
00503     Tmp0 = N0;
00504     Select(Tmp1, N1);
00505     if (N.Val->hasOneUse()) {
00506       Result = CurDAG->SelectNodeTo(N.Val, Alpha::LDAr, MVT::i64, Tmp0, Tmp1);
00507     } else {
00508       ResNode = CurDAG->getTargetNode(Alpha::LDAr, MVT::i64, Tmp0, Tmp1);
00509       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00510       Result = SDOperand(ResNode, 0);
00511     }
00512     return;
00513   }
00514 
00515   // Pattern: (Alpha_gprello:i64 (tconstpool:i64):$DISP, GPRC:i64:$RB)
00516   // Emits: (LDAr:i64 (tconstpool:i64):$DISP, GPRC:i64:$RB)
00517   // Pattern complexity = 4  cost = 1
00518   if (N0.getOpcode() == ISD::TargetConstantPool) {
00519     N1 = N.getOperand(1);
00520     Tmp0 = N0;
00521     Select(Tmp1, N1);
00522     if (N.Val->hasOneUse()) {
00523       Result = CurDAG->SelectNodeTo(N.Val, Alpha::LDAr, MVT::i64, Tmp0, Tmp1);
00524     } else {
00525       ResNode = CurDAG->getTargetNode(Alpha::LDAr, MVT::i64, Tmp0, Tmp1);
00526       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00527       Result = SDOperand(ResNode, 0);
00528     }
00529     return;
00530   }
00531   std::cerr << "Cannot yet select: ";
00532   N.Val->dump(CurDAG);
00533   std::cerr << '\n';
00534   abort();
00535 }
00536 
00537 void Select_Alpha_itoft(SDOperand &Result, SDOperand N) {
00538   SDOperand N0(0, 0);
00539   SDOperand Tmp0(0, 0);
00540   SDNode *ResNode;
00541   N0 = N.getOperand(0);
00542   if (N.Val->getValueType(0) == MVT::f64) {
00543     Select(Tmp0, N0);
00544     if (N.Val->hasOneUse()) {
00545       Result = CurDAG->SelectNodeTo(N.Val, Alpha::ITOFT, MVT::f64, Tmp0);
00546     } else {
00547       ResNode = CurDAG->getTargetNode(Alpha::ITOFT, MVT::f64, Tmp0);
00548       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00549       Result = SDOperand(ResNode, 0);
00550     }
00551     return;
00552   }
00553   std::cerr << "Cannot yet select: ";
00554   N.Val->dump(CurDAG);
00555   std::cerr << '\n';
00556   abort();
00557 }
00558 
00559 void Select_Alpha_rellit(SDOperand &Result, SDOperand N) {
00560   SDOperand N0(0, 0);
00561   SDOperand N1(0, 0);
00562   SDOperand Tmp0(0, 0);
00563   SDOperand Tmp1(0, 0);
00564   SDNode *ResNode;
00565   N0 = N.getOperand(0);
00566 
00567   // Pattern: (Alpha_rellit:i64 (tglobaladdr:i64):$DISP, GPRC:i64:$RB)
00568   // Emits: (LDQl:i64 (tglobaladdr:i64):$DISP, GPRC:i64:$RB)
00569   // Pattern complexity = 4  cost = 1
00570   if (N0.getOpcode() == ISD::TargetGlobalAddress) {
00571     N1 = N.getOperand(1);
00572     Tmp0 = N0;
00573     Select(Tmp1, N1);
00574     if (N.Val->hasOneUse()) {
00575       Result = CurDAG->SelectNodeTo(N.Val, Alpha::LDQl, MVT::i64, Tmp0, Tmp1);
00576     } else {
00577       ResNode = CurDAG->getTargetNode(Alpha::LDQl, MVT::i64, Tmp0, Tmp1);
00578       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00579       Result = SDOperand(ResNode, 0);
00580     }
00581     return;
00582   }
00583 
00584   // Pattern: (Alpha_rellit:i64 (texternalsym:i64):$ext, GPRC:i64:$RB)
00585   // Emits: (LDQl:i64 (texternalsym:i64):$ext, GPRC:i64:$RB)
00586   // Pattern complexity = 4  cost = 1
00587   if (N0.getOpcode() == ISD::TargetExternalSymbol) {
00588     N1 = N.getOperand(1);
00589     Tmp0 = N0;
00590     Select(Tmp1, N1);
00591     if (N.Val->hasOneUse()) {
00592       Result = CurDAG->SelectNodeTo(N.Val, Alpha::LDQl, MVT::i64, Tmp0, Tmp1);
00593     } else {
00594       ResNode = CurDAG->getTargetNode(Alpha::LDQl, MVT::i64, Tmp0, Tmp1);
00595       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00596       Result = SDOperand(ResNode, 0);
00597     }
00598     return;
00599   }
00600   std::cerr << "Cannot yet select: ";
00601   N.Val->dump(CurDAG);
00602   std::cerr << '\n';
00603   abort();
00604 }
00605 
00606 void Select_add(SDOperand &Result, SDOperand N) {
00607   SDOperand N0(0, 0);
00608   SDOperand N00(0, 0);
00609   SDOperand N01(0, 0);
00610   SDOperand N1(0, 0);
00611   SDOperand N10(0, 0);
00612   SDOperand N11(0, 0);
00613   SDOperand Tmp0(0, 0);
00614   SDOperand Tmp1(0, 0);
00615   SDOperand Tmp2(0, 0);
00616   SDOperand Tmp3(0, 0);
00617   SDNode *ResNode;
00618   N0 = N.getOperand(0);
00619   if (N0.getOpcode() == ISD::SHL) {
00620     N00 = N0.getOperand(0);
00621     N01 = N0.getOperand(1);
00622     if (isa<ConstantSDNode>(N01)) {
00623       int64_t CN0 = cast<ConstantSDNode>(N01)->getSignExtended();
00624 
00625       // Pattern: (add:i64 (shl:i64 GPRC:i64:$RA, 2:i64), (imm:i64)<<P:Predicate_immUExt8>>:$L)
00626       // Emits: (S4ADDQi:i64 GPRC:i64:$RA, (imm:i64):$L)
00627       // Pattern complexity = 10  cost = 1
00628       if (CN0 == 2) {
00629         N1 = N.getOperand(1);
00630         if (N1.getOpcode() == ISD::Constant &&
00631             Predicate_immUExt8(N1.Val)) {
00632           Select(Tmp1, N00);
00633           uint64_t Tmp2C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
00634           Tmp2 = CurDAG->getTargetConstant(Tmp2C, MVT::i64);
00635           if (N.Val->hasOneUse()) {
00636             Result = CurDAG->SelectNodeTo(N.Val, Alpha::S4ADDQi, MVT::i64, Tmp1, Tmp2);
00637           } else {
00638             ResNode = CurDAG->getTargetNode(Alpha::S4ADDQi, MVT::i64, Tmp1, Tmp2);
00639             SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00640             Result = SDOperand(ResNode, 0);
00641           }
00642           return;
00643         }
00644       }
00645       if (CN0 == 3) {
00646         N1 = N.getOperand(1);
00647         if (N1.getOpcode() == ISD::Constant) {
00648 
00649           // Pattern: (add:i64 (shl:i64 GPRC:i64:$RA, 3:i64), (imm:i64)<<P:Predicate_immUExt8>>:$L)
00650           // Emits: (S8ADDQi:i64 GPRC:i64:$RA, (imm:i64):$L)
00651           // Pattern complexity = 10  cost = 1
00652           if (Predicate_immUExt8(N1.Val)) {
00653             Select(Tmp1, N00);
00654             uint64_t Tmp2C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
00655             Tmp2 = CurDAG->getTargetConstant(Tmp2C, MVT::i64);
00656             if (N.Val->hasOneUse()) {
00657               Result = CurDAG->SelectNodeTo(N.Val, Alpha::S8ADDQi, MVT::i64, Tmp1, Tmp2);
00658             } else {
00659               ResNode = CurDAG->getTargetNode(Alpha::S8ADDQi, MVT::i64, Tmp1, Tmp2);
00660               SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00661               Result = SDOperand(ResNode, 0);
00662             }
00663             return;
00664           }
00665 
00666           // Pattern: (add:i64 (shl:i64 GPRC:i64:$RA, 3:i64), (imm:i64)<<P:Predicate_immUExt8neg>><<X:negX>>:$L)
00667           // Emits: (S8SUBQi:i64 GPRC:i64:$RA, (negX:i64 (imm:i64):$L))
00668           // Pattern complexity = 10  cost = 1
00669           if (Predicate_immUExt8neg(N1.Val)) {
00670             Select(Tmp1, N00);
00671             uint64_t Tmp2C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
00672             Tmp2 = CurDAG->getTargetConstant(Tmp2C, MVT::i64);
00673             Tmp3 = Transform_negX(Tmp2.Val);
00674             if (N.Val->hasOneUse()) {
00675               Result = CurDAG->SelectNodeTo(N.Val, Alpha::S8SUBQi, MVT::i64, Tmp1, Tmp3);
00676             } else {
00677               ResNode = CurDAG->getTargetNode(Alpha::S8SUBQi, MVT::i64, Tmp1, Tmp3);
00678               SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00679               Result = SDOperand(ResNode, 0);
00680             }
00681             return;
00682           }
00683         }
00684       }
00685 
00686       // Pattern: (add:i64 (shl:i64 GPRC:i64:$RA, 2:i64), GPRC:i64:$RB)
00687       // Emits: (S4ADDQ:i64 GPRC:i64:$RA, GPRC:i64:$RB)
00688       // Pattern complexity = 7  cost = 1
00689       if (CN0 == 2) {
00690         N1 = N.getOperand(1);
00691         Select(Tmp1, N00);
00692         Select(Tmp2, N1);
00693         if (N.Val->hasOneUse()) {
00694           Result = CurDAG->SelectNodeTo(N.Val, Alpha::S4ADDQ, MVT::i64, Tmp1, Tmp2);
00695         } else {
00696           ResNode = CurDAG->getTargetNode(Alpha::S4ADDQ, MVT::i64, Tmp1, Tmp2);
00697           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00698           Result = SDOperand(ResNode, 0);
00699         }
00700         return;
00701       }
00702 
00703       // Pattern: (add:i64 (shl:i64 GPRC:i64:$RA, 3:i64), GPRC:i64:$RB)
00704       // Emits: (S8ADDQ:i64 GPRC:i64:$RA, GPRC:i64:$RB)
00705       // Pattern complexity = 7  cost = 1
00706       if (CN0 == 3) {
00707         N1 = N.getOperand(1);
00708         Select(Tmp1, N00);
00709         Select(Tmp2, N1);
00710         if (N.Val->hasOneUse()) {
00711           Result = CurDAG->SelectNodeTo(N.Val, Alpha::S8ADDQ, MVT::i64, Tmp1, Tmp2);
00712         } else {
00713           ResNode = CurDAG->getTargetNode(Alpha::S8ADDQ, MVT::i64, Tmp1, Tmp2);
00714           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00715           Result = SDOperand(ResNode, 0);
00716         }
00717         return;
00718       }
00719     }
00720   }
00721   N1 = N.getOperand(1);
00722   if (N1.getOpcode() == ISD::SHL) {
00723     N10 = N1.getOperand(0);
00724     N11 = N1.getOperand(1);
00725     if (isa<ConstantSDNode>(N11)) {
00726       int64_t CN0 = cast<ConstantSDNode>(N11)->getSignExtended();
00727 
00728       // Pattern: (add:i64 GPRC:i64:$RB, (shl:i64 GPRC:i64:$RA, 2:i64))
00729       // Emits: (S4ADDQ:i64 GPRC:i64:$RA, GPRC:i64:$RB)
00730       // Pattern complexity = 7  cost = 1
00731       if (CN0 == 2) {
00732         Select(Tmp1, N10);
00733         Select(Tmp2, N0);
00734         if (N.Val->hasOneUse()) {
00735           Result = CurDAG->SelectNodeTo(N.Val, Alpha::S4ADDQ, MVT::i64, Tmp1, Tmp2);
00736         } else {
00737           ResNode = CurDAG->getTargetNode(Alpha::S4ADDQ, MVT::i64, Tmp1, Tmp2);
00738           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00739           Result = SDOperand(ResNode, 0);
00740         }
00741         return;
00742       }
00743 
00744       // Pattern: (add:i64 GPRC:i64:$RB, (shl:i64 GPRC:i64:$RA, 3:i64))
00745       // Emits: (S8ADDQ:i64 GPRC:i64:$RA, GPRC:i64:$RB)
00746       // Pattern complexity = 7  cost = 1
00747       if (CN0 == 3) {
00748         Select(Tmp1, N10);
00749         Select(Tmp2, N0);
00750         if (N.Val->hasOneUse()) {
00751           Result = CurDAG->SelectNodeTo(N.Val, Alpha::S8ADDQ, MVT::i64, Tmp1, Tmp2);
00752         } else {
00753           ResNode = CurDAG->getTargetNode(Alpha::S8ADDQ, MVT::i64, Tmp1, Tmp2);
00754           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00755           Result = SDOperand(ResNode, 0);
00756         }
00757         return;
00758       }
00759     }
00760   }
00761   if (N1.getOpcode() == ISD::Constant) {
00762 
00763     // Pattern: (add:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immUExt8>>:$L)
00764     // Emits: (ADDQi:i64 GPRC:i64:$RA, (imm:i64):$L)
00765     // Pattern complexity = 5  cost = 1
00766     if (Predicate_immUExt8(N1.Val)) {
00767       Select(Tmp0, N0);
00768       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
00769       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
00770       if (N.Val->hasOneUse()) {
00771         Result = CurDAG->SelectNodeTo(N.Val, Alpha::ADDQi, MVT::i64, Tmp0, Tmp1);
00772       } else {
00773         ResNode = CurDAG->getTargetNode(Alpha::ADDQi, MVT::i64, Tmp0, Tmp1);
00774         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00775         Result = SDOperand(ResNode, 0);
00776       }
00777       return;
00778     }
00779 
00780     // Pattern: (add:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immUExt8neg>><<X:negX>>:$L)
00781     // Emits: (SUBQi:i64 GPRC:i64:$RA, (negX:i64 (imm:i64):$L))
00782     // Pattern complexity = 5  cost = 1
00783     if (Predicate_immUExt8neg(N1.Val)) {
00784       Select(Tmp0, N0);
00785       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
00786       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
00787       Tmp2 = Transform_negX(Tmp1.Val);
00788       if (N.Val->hasOneUse()) {
00789         Result = CurDAG->SelectNodeTo(N.Val, Alpha::SUBQi, MVT::i64, Tmp0, Tmp2);
00790       } else {
00791         ResNode = CurDAG->getTargetNode(Alpha::SUBQi, MVT::i64, Tmp0, Tmp2);
00792         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00793         Result = SDOperand(ResNode, 0);
00794       }
00795       return;
00796     }
00797 
00798     // Pattern: (add:i64 GPRC:i64:$RB, (imm:i64)<<P:Predicate_immSExt16>>:$DISP)
00799     // Emits: (LDA:i64 (imm:i64):$DISP, GPRC:i64:$RB)
00800     // Pattern complexity = 5  cost = 1
00801     if (Predicate_immSExt16(N1.Val)) {
00802       uint64_t Tmp0C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
00803       Tmp0 = CurDAG->getTargetConstant(Tmp0C, MVT::i64);
00804       Select(Tmp1, N0);
00805       if (N.Val->hasOneUse()) {
00806         Result = CurDAG->SelectNodeTo(N.Val, Alpha::LDA, MVT::i64, Tmp0, Tmp1);
00807       } else {
00808         ResNode = CurDAG->getTargetNode(Alpha::LDA, MVT::i64, Tmp0, Tmp1);
00809         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00810         Result = SDOperand(ResNode, 0);
00811       }
00812       return;
00813     }
00814   }
00815 
00816   // Pattern: (add:i64 GPRC:i64:$RA, GPRC:i64:$RB)
00817   // Emits: (ADDQ:i64 GPRC:i64:$RA, GPRC:i64:$RB)
00818   // Pattern complexity = 2  cost = 1
00819   Select(Tmp0, N0);
00820   Select(Tmp1, N1);
00821   if (N.Val->hasOneUse()) {
00822     Result = CurDAG->SelectNodeTo(N.Val, Alpha::ADDQ, MVT::i64, Tmp0, Tmp1);
00823   } else {
00824     ResNode = CurDAG->getTargetNode(Alpha::ADDQ, MVT::i64, Tmp0, Tmp1);
00825     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00826     Result = SDOperand(ResNode, 0);
00827   }
00828   return;
00829 }
00830 
00831 void Select_and(SDOperand &Result, SDOperand N) {
00832   SDOperand N0(0, 0);
00833   SDOperand N00(0, 0);
00834   SDOperand N01(0, 0);
00835   SDOperand N010(0, 0);
00836   SDOperand N011(0, 0);
00837   SDOperand N1(0, 0);
00838   SDOperand N10(0, 0);
00839   SDOperand N11(0, 0);
00840   SDOperand N110(0, 0);
00841   SDOperand N111(0, 0);
00842   SDOperand Tmp0(0, 0);
00843   SDOperand Tmp1(0, 0);
00844   SDOperand Tmp2(0, 0);
00845   SDOperand Tmp3(0, 0);
00846   SDNode *ResNode;
00847   N0 = N.getOperand(0);
00848   if (N0.getOpcode() == ISD::SRL) {
00849     N00 = N0.getOperand(0);
00850     N01 = N0.getOperand(1);
00851     if (N01.getOpcode() == ISD::SHL) {
00852       N010 = N01.getOperand(0);
00853       N011 = N01.getOperand(1);
00854       if (isa<ConstantSDNode>(N011)) {
00855         int64_t CN0 = cast<ConstantSDNode>(N011)->getSignExtended();
00856         if (CN0 == 3) {
00857           N1 = N.getOperand(1);
00858           if (isa<ConstantSDNode>(N1)) {
00859             int64_t CN1 = cast<ConstantSDNode>(N1)->getSignExtended();
00860 
00861             // Pattern: (and:i64 (srl:i64 GPRC:i64:$RA, (shl:i64 GPRC:i64:$RB, 3:i64)), 255:i64)
00862             // Emits: (EXTBL:i64 GPRC:i64:$RA, GPRC:i64:$RB)
00863             // Pattern complexity = 12  cost = 1
00864             if (CN1 == 255) {
00865               Select(Tmp2, N00);
00866               Select(Tmp3, N010);
00867               if (N.Val->hasOneUse()) {
00868                 Result = CurDAG->SelectNodeTo(N.Val, Alpha::EXTBL, MVT::i64, Tmp2, Tmp3);
00869               } else {
00870                 ResNode = CurDAG->getTargetNode(Alpha::EXTBL, MVT::i64, Tmp2, Tmp3);
00871                 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00872                 Result = SDOperand(ResNode, 0);
00873               }
00874               return;
00875             }
00876 
00877             // Pattern: (and:i64 (srl:i64 GPRC:i64:$RA, (shl:i64 GPRC:i64:$RB, 3:i64)), 65535:i64)
00878             // Emits: (EXTWL:i64 GPRC:i64:$RA, GPRC:i64:$RB)
00879             // Pattern complexity = 12  cost = 1
00880             if (CN1 == 65535) {
00881               Select(Tmp2, N00);
00882               Select(Tmp3, N010);
00883               if (N.Val->hasOneUse()) {
00884                 Result = CurDAG->SelectNodeTo(N.Val, Alpha::EXTWL, MVT::i64, Tmp2, Tmp3);
00885               } else {
00886                 ResNode = CurDAG->getTargetNode(Alpha::EXTWL, MVT::i64, Tmp2, Tmp3);
00887                 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00888                 Result = SDOperand(ResNode, 0);
00889               }
00890               return;
00891             }
00892 
00893             // Pattern: (and:i64 (srl:i64 GPRC:i64:$RA, (shl:i64 GPRC:i64:$RB, 3:i64)), 2147483647:i64)
00894             // Emits: (EXTLL:i64 GPRC:i64:$RA, GPRC:i64:$RB)
00895             // Pattern complexity = 12  cost = 1
00896             if (CN1 == 2147483647) {
00897               Select(Tmp2, N00);
00898               Select(Tmp3, N010);
00899               if (N.Val->hasOneUse()) {
00900                 Result = CurDAG->SelectNodeTo(N.Val, Alpha::EXTLL, MVT::i64, Tmp2, Tmp3);
00901               } else {
00902                 ResNode = CurDAG->getTargetNode(Alpha::EXTLL, MVT::i64, Tmp2, Tmp3);
00903                 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00904                 Result = SDOperand(ResNode, 0);
00905               }
00906               return;
00907             }
00908           }
00909         }
00910       }
00911     }
00912   }
00913   if (isa<ConstantSDNode>(N0)) {
00914     int64_t CN0 = cast<ConstantSDNode>(N0)->getSignExtended();
00915 
00916     // Pattern: (and:i64 255:i64, (srl:i64 GPRC:i64:$RA, (shl:i64 GPRC:i64:$RB, 3:i64)))
00917     // Emits: (EXTBL:i64 GPRC:i64:$RA, GPRC:i64:$RB)
00918     // Pattern complexity = 12  cost = 1
00919     if (CN0 == 255) {
00920       N1 = N.getOperand(1);
00921       if (N1.getOpcode() == ISD::SRL) {
00922         N10 = N1.getOperand(0);
00923         N11 = N1.getOperand(1);
00924         if (N11.getOpcode() == ISD::SHL) {
00925           N110 = N11.getOperand(0);
00926           N111 = N11.getOperand(1);
00927           if (isa<ConstantSDNode>(N111)) {
00928             int64_t CN1 = cast<ConstantSDNode>(N111)->getSignExtended();
00929             if (CN1 == 3) {
00930               Select(Tmp2, N10);
00931               Select(Tmp3, N110);
00932               if (N.Val->hasOneUse()) {
00933                 Result = CurDAG->SelectNodeTo(N.Val, Alpha::EXTBL, MVT::i64, Tmp2, Tmp3);
00934               } else {
00935                 ResNode = CurDAG->getTargetNode(Alpha::EXTBL, MVT::i64, Tmp2, Tmp3);
00936                 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00937                 Result = SDOperand(ResNode, 0);
00938               }
00939               return;
00940             }
00941           }
00942         }
00943       }
00944     }
00945 
00946     // Pattern: (and:i64 65535:i64, (srl:i64 GPRC:i64:$RA, (shl:i64 GPRC:i64:$RB, 3:i64)))
00947     // Emits: (EXTWL:i64 GPRC:i64:$RA, GPRC:i64:$RB)
00948     // Pattern complexity = 12  cost = 1
00949     if (CN0 == 65535) {
00950       N1 = N.getOperand(1);
00951       if (N1.getOpcode() == ISD::SRL) {
00952         N10 = N1.getOperand(0);
00953         N11 = N1.getOperand(1);
00954         if (N11.getOpcode() == ISD::SHL) {
00955           N110 = N11.getOperand(0);
00956           N111 = N11.getOperand(1);
00957           if (isa<ConstantSDNode>(N111)) {
00958             int64_t CN1 = cast<ConstantSDNode>(N111)->getSignExtended();
00959             if (CN1 == 3) {
00960               Select(Tmp2, N10);
00961               Select(Tmp3, N110);
00962               if (N.Val->hasOneUse()) {
00963                 Result = CurDAG->SelectNodeTo(N.Val, Alpha::EXTWL, MVT::i64, Tmp2, Tmp3);
00964               } else {
00965                 ResNode = CurDAG->getTargetNode(Alpha::EXTWL, MVT::i64, Tmp2, Tmp3);
00966                 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00967                 Result = SDOperand(ResNode, 0);
00968               }
00969               return;
00970             }
00971           }
00972         }
00973       }
00974     }
00975 
00976     // Pattern: (and:i64 2147483647:i64, (srl:i64 GPRC:i64:$RA, (shl:i64 GPRC:i64:$RB, 3:i64)))
00977     // Emits: (EXTLL:i64 GPRC:i64:$RA, GPRC:i64:$RB)
00978     // Pattern complexity = 12  cost = 1
00979     if (CN0 == 2147483647) {
00980       N1 = N.getOperand(1);
00981       if (N1.getOpcode() == ISD::SRL) {
00982         N10 = N1.getOperand(0);
00983         N11 = N1.getOperand(1);
00984         if (N11.getOpcode() == ISD::SHL) {
00985           N110 = N11.getOperand(0);
00986           N111 = N11.getOperand(1);
00987           if (isa<ConstantSDNode>(N111)) {
00988             int64_t CN1 = cast<ConstantSDNode>(N111)->getSignExtended();
00989             if (CN1 == 3) {
00990               Select(Tmp2, N10);
00991               Select(Tmp3, N110);
00992               if (N.Val->hasOneUse()) {
00993                 Result = CurDAG->SelectNodeTo(N.Val, Alpha::EXTLL, MVT::i64, Tmp2, Tmp3);
00994               } else {
00995                 ResNode = CurDAG->getTargetNode(Alpha::EXTLL, MVT::i64, Tmp2, Tmp3);
00996                 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
00997                 Result = SDOperand(ResNode, 0);
00998               }
00999               return;
01000             }
01001           }
01002         }
01003       }
01004     }
01005   }
01006 
01007   // Pattern: (and:i64 GPRC:i64:$RA, (xor:i64 GPRC:i64:$RB, (imm:i64)<<P:Predicate_immAllOnes>>))
01008   // Emits: (BIC:i64 GPRC:i64:$RA, GPRC:i64:$RB)
01009   // Pattern complexity = 7  cost = 1
01010   {
01011     N1 = N.getOperand(1);
01012     if (N1.getOpcode() == ISD::XOR) {
01013       N10 = N1.getOperand(0);
01014       N11 = N1.getOperand(1);
01015       if (N11.getOpcode() == ISD::Constant &&
01016           Predicate_immAllOnes(N11.Val)) {
01017         Select(Tmp0, N0);
01018         Select(Tmp1, N10);
01019         if (N.Val->hasOneUse()) {
01020           Result = CurDAG->SelectNodeTo(N.Val, Alpha::BIC, MVT::i64, Tmp0, Tmp1);
01021         } else {
01022           ResNode = CurDAG->getTargetNode(Alpha::BIC, MVT::i64, Tmp0, Tmp1);
01023           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
01024           Result = SDOperand(ResNode, 0);
01025         }
01026         return;
01027       }
01028     }
01029   }
01030 
01031   // Pattern: (and:i64 (xor:i64 GPRC:i64:$RB, (imm:i64)<<P:Predicate_immAllOnes>>), GPRC:i64:$RA)
01032   // Emits: (BIC:i64 GPRC:i64:$RA, GPRC:i64:$RB)
01033   // Pattern complexity = 7  cost = 1
01034   if (N0.getOpcode() == ISD::XOR) {
01035     N00 = N0.getOperand(0);
01036     N01 = N0.getOperand(1);
01037     if (N01.getOpcode() == ISD::Constant &&
01038         Predicate_immAllOnes(N01.Val)) {
01039       N1 = N.getOperand(1);
01040       Select(Tmp0, N1);
01041       Select(Tmp1, N00);
01042       if (N.Val->hasOneUse()) {
01043         Result = CurDAG->SelectNodeTo(N.Val, Alpha::BIC, MVT::i64, Tmp0, Tmp1);
01044       } else {
01045         ResNode = CurDAG->getTargetNode(Alpha::BIC, MVT::i64, Tmp0, Tmp1);
01046         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
01047         Result = SDOperand(ResNode, 0);
01048       }
01049       return;
01050     }
01051   }
01052   N1 = N.getOperand(1);
01053   if (N1.getOpcode() == ISD::Constant) {
01054 
01055     // Pattern: (and:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immUExt8>>:$L)
01056     // Emits: (ANDi:i64 GPRC:i64:$RA, (imm:i64):$L)
01057     // Pattern complexity = 5  cost = 1
01058     if (Predicate_immUExt8(N1.Val)) {
01059       Select(Tmp0, N0);
01060       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
01061       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
01062       if (N.Val->hasOneUse()) {
01063         Result = CurDAG->SelectNodeTo(N.Val, Alpha::ANDi, MVT::i64, Tmp0, Tmp1);
01064       } else {
01065         ResNode = CurDAG->getTargetNode(Alpha::ANDi, MVT::i64, Tmp0, Tmp1);
01066         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
01067         Result = SDOperand(ResNode, 0);
01068       }
01069       return;
01070     }
01071 
01072     // Pattern: (and:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immUExt8inv>><<X:invX>>:$L)
01073     // Emits: (BICi:i64 GPRC:i64:$RA, (invX:i64 (imm:i64):$L))
01074     // Pattern complexity = 5  cost = 1
01075     if (Predicate_immUExt8inv(N1.Val)) {
01076       Select(Tmp0, N0);
01077       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
01078       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
01079       Tmp2 = Transform_invX(Tmp1.Val);
01080       if (N.Val->hasOneUse()) {
01081         Result = CurDAG->SelectNodeTo(N.Val, Alpha::BICi, MVT::i64, Tmp0, Tmp2);
01082       } else {
01083         ResNode = CurDAG->getTargetNode(Alpha::BICi, MVT::i64, Tmp0, Tmp2);
01084         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
01085         Result = SDOperand(ResNode, 0);
01086       }
01087       return;
01088     }
01089 
01090     // Pattern: (and:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immZAP>><<X:iZAPX>>:$L)
01091     // Emits: (ZAPNOTi:i64 GPRC:i64:$RA, (iZAPX:i64 (imm:i64):$L))
01092     // Pattern complexity = 5  cost = 1
01093     if (Predicate_immZAP(N1.Val)) {
01094       Select(Tmp0, N0);
01095       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
01096       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
01097       Tmp2 = Transform_iZAPX(Tmp1.Val);
01098       if (N.Val->hasOneUse()) {
01099         Result = CurDAG->SelectNodeTo(N.Val, Alpha::ZAPNOTi, MVT::i64, Tmp0, Tmp2);
01100       } else {
01101         ResNode = CurDAG->getTargetNode(Alpha::ZAPNOTi, MVT::i64, Tmp0, Tmp2);
01102         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
01103         Result = SDOperand(ResNode, 0);
01104       }
01105       return;
01106     }
01107   }
01108 
01109   // Pattern: (and:i64 GPRC:i64:$RA, GPRC:i64:$RB)
01110   // Emits: (AND:i64 GPRC:i64:$RA, GPRC:i64:$RB)
01111   // Pattern complexity = 2  cost = 1
01112   Select(Tmp0, N0);
01113   Select(Tmp1, N1);
01114   if (N.Val->hasOneUse()) {
01115     Result = CurDAG->SelectNodeTo(N.Val, Alpha::AND, MVT::i64, Tmp0, Tmp1);
01116   } else {
01117     ResNode = CurDAG->getTargetNode(Alpha::AND, MVT::i64, Tmp0, Tmp1);
01118     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
01119     Result = SDOperand(ResNode, 0);
01120   }
01121   return;
01122 }
01123 
01124 void Select_br(SDOperand &Result, SDOperand N) {
01125   SDOperand Chain(0, 0);
01126   SDOperand N1(0, 0);
01127   SDOperand Tmp0(0, 0);
01128   SDNode *ResNode;
01129   Chain = N.getOperand(0);
01130   N1 = N.getOperand(1);
01131   if (N1.getOpcode() == ISD::BasicBlock) {
01132     Select(Tmp0, N1);
01133     Select(Chain, Chain);
01134     ResNode = CurDAG->getTargetNode(Alpha::BR, MVT::Other, Tmp0, Chain);
01135     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01136     Result = SDOperand(ResNode, N.ResNo);
01137     return;
01138   }
01139   std::cerr << "Cannot yet select: ";
01140   N.Val->dump(CurDAG);
01141   std::cerr << '\n';
01142   abort();
01143 }
01144 
01145 void Select_brcond(SDOperand &Result, SDOperand N) {
01146   SDOperand Chain(0, 0);
01147   SDOperand N1(0, 0);
01148   SDOperand N10(0, 0);
01149   SDOperand N11(0, 0);
01150   SDOperand N12(0, 0);
01151   SDOperand N2(0, 0);
01152   SDOperand Tmp0(0, 0);
01153   SDOperand Tmp1(0, 0);
01154   SDOperand Tmp2(0, 0);
01155   SDOperand Tmp3(0, 0);
01156   SDNode *ResNode;
01157   Chain = N.getOperand(0);
01158   N1 = N.getOperand(1);
01159   if (N1.getOpcode() == ISD::SETCC) {
01160     N10 = N1.getOperand(0);
01161     N11 = N1.getOperand(1);
01162     if (isa<ConstantSDNode>(N11)) {
01163       int64_t CN0 = cast<ConstantSDNode>(N11)->getSignExtended();
01164       if (CN0 == 0) {
01165         N12 = N1.getOperand(2);
01166 
01167         // Pattern: (brcond:void (setcc:i64 GPRC:i64:$RA, 0:i64, SETEQ:Other), (bb:Other):$DISP)
01168         // Emits: (BEQ:void GPRC:i64:$RA, (bb:Other):$DISP)
01169         // Pattern complexity = 7  cost = 1
01170         if (cast<CondCodeSDNode>(N12)->get() == ISD::SETEQ) {
01171           N2 = N.getOperand(2);
01172           if (N2.getOpcode() == ISD::BasicBlock &&
01173               N10.Val->getValueType(0) == MVT::i64) {
01174             Select(Tmp1, N10);
01175             Select(Tmp2, N2);
01176             Select(Chain, Chain);
01177             ResNode = CurDAG->getTargetNode(Alpha::BEQ, MVT::Other, Tmp1, Tmp2, Chain);
01178             SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01179             Result = SDOperand(ResNode, N.ResNo);
01180             return;
01181           }
01182         }
01183 
01184         // Pattern: (brcond:void (setcc:i64 GPRC:i64:$RA, 0:i64, SETGE:Other), (bb:Other):$DISP)
01185         // Emits: (BGE:void GPRC:i64:$RA, (bb:Other):$DISP)
01186         // Pattern complexity = 7  cost = 1
01187         if (cast<CondCodeSDNode>(N12)->get() == ISD::SETGE) {
01188           N2 = N.getOperand(2);
01189           if (N2.getOpcode() == ISD::BasicBlock &&
01190               N10.Val->getValueType(0) == MVT::i64) {
01191             Select(Tmp1, N10);
01192             Select(Tmp2, N2);
01193             Select(Chain, Chain);
01194             ResNode = CurDAG->getTargetNode(Alpha::BGE, MVT::Other, Tmp1, Tmp2, Chain);
01195             SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01196             Result = SDOperand(ResNode, N.ResNo);
01197             return;
01198           }
01199         }
01200 
01201         // Pattern: (brcond:void (setcc:i64 GPRC:i64:$RA, 0:i64, SETGT:Other), (bb:Other):$DISP)
01202         // Emits: (BGT:void GPRC:i64:$RA, (bb:Other):$DISP)
01203         // Pattern complexity = 7  cost = 1
01204         if (cast<CondCodeSDNode>(N12)->get() == ISD::SETGT) {
01205           N2 = N.getOperand(2);
01206           if (N2.getOpcode() == ISD::BasicBlock &&
01207               N10.Val->getValueType(0) == MVT::i64) {
01208             Select(Tmp1, N10);
01209             Select(Tmp2, N2);
01210             Select(Chain, Chain);
01211             ResNode = CurDAG->getTargetNode(Alpha::BGT, MVT::Other, Tmp1, Tmp2, Chain);
01212             SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01213             Result = SDOperand(ResNode, N.ResNo);
01214             return;
01215           }
01216         }
01217       }
01218     }
01219   }
01220 
01221   // Pattern: (brcond:void (and:i64 GPRC:i64:$RA, 1:i64), (bb:Other):$DISP)
01222   // Emits: (BLBS:void GPRC:i64:$RA, (bb:Other):$DISP)
01223   // Pattern complexity = 7  cost = 1
01224   if (N1.getOpcode() == ISD::AND) {
01225     N10 = N1.getOperand(0);
01226     N11 = N1.getOperand(1);
01227     if (isa<ConstantSDNode>(N11)) {
01228       int64_t CN0 = cast<ConstantSDNode>(N11)->getSignExtended();
01229       if (CN0 == 1) {
01230         N2 = N.getOperand(2);
01231         if (N2.getOpcode() == ISD::BasicBlock) {
01232           Select(Tmp1, N10);
01233           Select(Tmp2, N2);
01234           Select(Chain, Chain);
01235           ResNode = CurDAG->getTargetNode(Alpha::BLBS, MVT::Other, Tmp1, Tmp2, Chain);
01236           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01237           Result = SDOperand(ResNode, N.ResNo);
01238           return;
01239         }
01240       }
01241     }
01242   }
01243   if (N1.getOpcode() == ISD::SETCC) {
01244     N10 = N1.getOperand(0);
01245     N11 = N1.getOperand(1);
01246     if (isa<ConstantSDNode>(N11)) {
01247       int64_t CN0 = cast<ConstantSDNode>(N11)->getSignExtended();
01248       if (CN0 == 0) {
01249         N12 = N1.getOperand(2);
01250 
01251         // Pattern: (brcond:void (setcc:i64 GPRC:i64:$RA, 0:i64, SETLE:Other), (bb:Other):$DISP)
01252         // Emits: (BLE:void GPRC:i64:$RA, (bb:Other):$DISP)
01253         // Pattern complexity = 7  cost = 1
01254         if (cast<CondCodeSDNode>(N12)->get() == ISD::SETLE) {
01255           N2 = N.getOperand(2);
01256           if (N2.getOpcode() == ISD::BasicBlock &&
01257               N10.Val->getValueType(0) == MVT::i64) {
01258             Select(Tmp1, N10);
01259             Select(Tmp2, N2);
01260             Select(Chain, Chain);
01261             ResNode = CurDAG->getTargetNode(Alpha::BLE, MVT::Other, Tmp1, Tmp2, Chain);
01262             SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01263             Result = SDOperand(ResNode, N.ResNo);
01264             return;
01265           }
01266         }
01267 
01268         // Pattern: (brcond:void (setcc:i64 GPRC:i64:$RA, 0:i64, SETLT:Other), (bb:Other):$DISP)
01269         // Emits: (BLT:void GPRC:i64:$RA, (bb:Other):$DISP)
01270         // Pattern complexity = 7  cost = 1
01271         if (cast<CondCodeSDNode>(N12)->get() == ISD::SETLT) {
01272           N2 = N.getOperand(2);
01273           if (N2.getOpcode() == ISD::BasicBlock &&
01274               N10.Val->getValueType(0) == MVT::i64) {
01275             Select(Tmp1, N10);
01276             Select(Tmp2, N2);
01277             Select(Chain, Chain);
01278             ResNode = CurDAG->getTargetNode(Alpha::BLT, MVT::Other, Tmp1, Tmp2, Chain);
01279             SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01280             Result = SDOperand(ResNode, N.ResNo);
01281             return;
01282           }
01283         }
01284 
01285         // Pattern: (brcond:void (setcc:i64 GPRC:i64:$RA, 0:i64, SETNE:Other), (bb:Other):$DISP)
01286         // Emits: (BNE:void GPRC:i64:$RA, (bb:Other):$DISP)
01287         // Pattern complexity = 7  cost = 1
01288         if (cast<CondCodeSDNode>(N12)->get() == ISD::SETNE) {
01289           N2 = N.getOperand(2);
01290           if (N2.getOpcode() == ISD::BasicBlock &&
01291               N10.Val->getValueType(0) == MVT::i64) {
01292             Select(Tmp1, N10);
01293             Select(Tmp2, N2);
01294             Select(Chain, Chain);
01295             ResNode = CurDAG->getTargetNode(Alpha::BNE, MVT::Other, Tmp1, Tmp2, Chain);
01296             SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01297             Result = SDOperand(ResNode, N.ResNo);
01298             return;
01299           }
01300         }
01301       }
01302     }
01303     if (N11.getOpcode() == ISD::TargetConstantFP &&
01304         Predicate_immFPZ(N11.Val)) {
01305       N12 = N1.getOperand(2);
01306 
01307       // Pattern: (brcond:void (setcc:i64 F8RC:f64:$RA, (fpimm:f64)<<P:Predicate_immFPZ>>, SETEQ:Other), (bb:Other):$DISP)
01308       // Emits: (FBEQ:void F8RC:f64:$RA, (bb:Other):$DISP)
01309       // Pattern complexity = 7  cost = 1
01310       if (cast<CondCodeSDNode>(N12)->get() == ISD::SETEQ) {
01311         N2 = N.getOperand(2);
01312         if (N2.getOpcode() == ISD::BasicBlock &&
01313             N10.Val->getValueType(0) == MVT::f64) {
01314           Select(Tmp0, N10);
01315           Select(Tmp1, N2);
01316           Select(Chain, Chain);
01317           ResNode = CurDAG->getTargetNode(Alpha::FBEQ, MVT::Other, Tmp0, Tmp1, Chain);
01318           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01319           Result = SDOperand(ResNode, N.ResNo);
01320           return;
01321         }
01322       }
01323 
01324       // Pattern: (brcond:void (setcc:i64 F8RC:f64:$RA, (fpimm:f64)<<P:Predicate_immFPZ>>, SETGE:Other), (bb:Other):$DISP)
01325       // Emits: (FBGE:void F8RC:f64:$RA, (bb:Other):$DISP)
01326       // Pattern complexity = 7  cost = 1
01327       if (cast<CondCodeSDNode>(N12)->get() == ISD::SETGE) {
01328         N2 = N.getOperand(2);
01329         if (N2.getOpcode() == ISD::BasicBlock &&
01330             N10.Val->getValueType(0) == MVT::f64) {
01331           Select(Tmp0, N10);
01332           Select(Tmp1, N2);
01333           Select(Chain, Chain);
01334           ResNode = CurDAG->getTargetNode(Alpha::FBGE, MVT::Other, Tmp0, Tmp1, Chain);
01335           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01336           Result = SDOperand(ResNode, N.ResNo);
01337           return;
01338         }
01339       }
01340 
01341       // Pattern: (brcond:void (setcc:i64 F8RC:f64:$RA, (fpimm:f64)<<P:Predicate_immFPZ>>, SETGT:Other), (bb:Other):$DISP)
01342       // Emits: (FBGT:void F8RC:f64:$RA, (bb:Other):$DISP)
01343       // Pattern complexity = 7  cost = 1
01344       if (cast<CondCodeSDNode>(N12)->get() == ISD::SETGT) {
01345         N2 = N.getOperand(2);
01346         if (N2.getOpcode() == ISD::BasicBlock &&
01347             N10.Val->getValueType(0) == MVT::f64) {
01348           Select(Tmp0, N10);
01349           Select(Tmp1, N2);
01350           Select(Chain, Chain);
01351           ResNode = CurDAG->getTargetNode(Alpha::FBGT, MVT::Other, Tmp0, Tmp1, Chain);
01352           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01353           Result = SDOperand(ResNode, N.ResNo);
01354           return;
01355         }
01356       }
01357 
01358       // Pattern: (brcond:void (setcc:i64 F8RC:f64:$RA, (fpimm:f64)<<P:Predicate_immFPZ>>, SETLE:Other), (bb:Other):$DISP)
01359       // Emits: (FBLE:void F8RC:f64:$RA, (bb:Other):$DISP)
01360       // Pattern complexity = 7  cost = 1
01361       if (cast<CondCodeSDNode>(N12)->get() == ISD::SETLE) {
01362         N2 = N.getOperand(2);
01363         if (N2.getOpcode() == ISD::BasicBlock &&
01364             N10.Val->getValueType(0) == MVT::f64) {
01365           Select(Tmp0, N10);
01366           Select(Tmp1, N2);
01367           Select(Chain, Chain);
01368           ResNode = CurDAG->getTargetNode(Alpha::FBLE, MVT::Other, Tmp0, Tmp1, Chain);
01369           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01370           Result = SDOperand(ResNode, N.ResNo);
01371           return;
01372         }
01373       }
01374 
01375       // Pattern: (brcond:void (setcc:i64 F8RC:f64:$RA, (fpimm:f64)<<P:Predicate_immFPZ>>, SETLT:Other), (bb:Other):$DISP)
01376       // Emits: (FBLT:void F8RC:f64:$RA, (bb:Other):$DISP)
01377       // Pattern complexity = 7  cost = 1
01378       if (cast<CondCodeSDNode>(N12)->get() == ISD::SETLT) {
01379         N2 = N.getOperand(2);
01380         if (N2.getOpcode() == ISD::BasicBlock &&
01381             N10.Val->getValueType(0) == MVT::f64) {
01382           Select(Tmp0, N10);
01383           Select(Tmp1, N2);
01384           Select(Chain, Chain);
01385           ResNode = CurDAG->getTargetNode(Alpha::FBLT, MVT::Other, Tmp0, Tmp1, Chain);
01386           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01387           Result = SDOperand(ResNode, N.ResNo);
01388           return;
01389         }
01390       }
01391 
01392       // Pattern: (brcond:void (setcc:i64 F8RC:f64:$RA, (fpimm:f64)<<P:Predicate_immFPZ>>, SETNE:Other), (bb:Other):$DISP)
01393       // Emits: (FBNE:void F8RC:f64:$RA, (bb:Other):$DISP)
01394       // Pattern complexity = 7  cost = 1
01395       if (cast<CondCodeSDNode>(N12)->get() == ISD::SETNE) {
01396         N2 = N.getOperand(2);
01397         if (N2.getOpcode() == ISD::BasicBlock &&
01398             N10.Val->getValueType(0) == MVT::f64) {
01399           Select(Tmp0, N10);
01400           Select(Tmp1, N2);
01401           Select(Chain, Chain);
01402           ResNode = CurDAG->getTargetNode(Alpha::FBNE, MVT::Other, Tmp0, Tmp1, Chain);
01403           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01404           Result = SDOperand(ResNode, N.ResNo);
01405           return;
01406         }
01407       }
01408     }
01409   }
01410 
01411   // Pattern: (brcond:void (and:i64 1:i64, GPRC:i64:$RA), (bb:Other):$DISP)
01412   // Emits: (BLBS:void GPRC:i64:$RA, (bb:Other):$DISP)
01413   // Pattern complexity = 7  cost = 1
01414   if (N1.getOpcode() == ISD::AND) {
01415     N10 = N1.getOperand(0);
01416     if (isa<ConstantSDNode>(N10)) {
01417       int64_t CN0 = cast<ConstantSDNode>(N10)->getSignExtended();
01418       if (CN0 == 1) {
01419         N11 = N1.getOperand(1);
01420         N2 = N.getOperand(2);
01421         if (N2.getOpcode() == ISD::BasicBlock) {
01422           Select(Tmp1, N11);
01423           Select(Tmp2, N2);
01424           Select(Chain, Chain);
01425           ResNode = CurDAG->getTargetNode(Alpha::BLBS, MVT::Other, Tmp1, Tmp2, Chain);
01426           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01427           Result = SDOperand(ResNode, N.ResNo);
01428           return;
01429         }
01430       }
01431     }
01432   }
01433   if (N1.getOpcode() == ISD::SETCC) {
01434     N10 = N1.getOperand(0);
01435     N11 = N1.getOperand(1);
01436 
01437     // Pattern: (brcond:void (setcc:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immUExt8>>:$L, SETNE:Other), (bb:Other):$DISP)
01438     // Emits: (BEQ:void (CMPEQi:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immUExt8>>:$L), (bb:Other):$DISP)
01439     // Pattern complexity = 7  cost = 2
01440     if (N11.getOpcode() == ISD::Constant &&
01441         Predicate_immUExt8(N11.Val)) {
01442       N12 = N1.getOperand(2);
01443       if (cast<CondCodeSDNode>(N12)->get() == ISD::SETNE) {
01444         N2 = N.getOperand(2);
01445         if (N2.getOpcode() == ISD::BasicBlock) {
01446           Select(Tmp0, N10);
01447           uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N11)->getValue();
01448           Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
01449           Tmp2 = SDOperand(CurDAG->getTargetNode(Alpha::CMPEQi, MVT::i64, Tmp0, Tmp1), 0);
01450           Select(Tmp3, N2);
01451           Select(Chain, Chain);
01452           ResNode = CurDAG->getTargetNode(Alpha::BEQ, MVT::Other, Tmp2, Tmp3, Chain);
01453           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01454           Result = SDOperand(ResNode, N.ResNo);
01455           return;
01456         }
01457       }
01458     }
01459     N12 = N1.getOperand(2);
01460 
01461     // Pattern: (brcond:void (setcc:i64 GPRC:i64:$RA, GPRC:i64:$RB, SETNE:Other), (bb:Other):$DISP)
01462     // Emits: (BEQ:void (CMPEQ:i64 GPRC:i64:$RA, GPRC:i64:$RB), (bb:Other):$DISP)
01463     // Pattern complexity = 4  cost = 2
01464     if (cast<CondCodeSDNode>(N12)->get() == ISD::SETNE) {
01465       N2 = N.getOperand(2);
01466       if (N2.getOpcode() == ISD::BasicBlock &&
01467           N10.Val->getValueType(0) == MVT::i64) {
01468         Select(Tmp0, N10);
01469         Select(Tmp1, N11);
01470         Tmp2 = SDOperand(CurDAG->getTargetNode(Alpha::CMPEQ, MVT::i64, Tmp0, Tmp1), 0);
01471         Select(Tmp3, N2);
01472         Select(Chain, Chain);
01473         ResNode = CurDAG->getTargetNode(Alpha::BEQ, MVT::Other, Tmp2, Tmp3, Chain);
01474         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01475         Result = SDOperand(ResNode, N.ResNo);
01476         return;
01477       }
01478     }
01479 
01480     // Pattern: (brcond:void (setcc:i64 F8RC:f64:$RA, F8RC:f64:$RB, SETEQ:Other), (bb:Other):$DISP)
01481     // Emits: (FBNE:void (CMPTEQ:f64 F8RC:f64:$RA, F8RC:f64:$RB), (bb:Other):$DISP)
01482     // Pattern complexity = 4  cost = 2
01483     if (cast<CondCodeSDNode>(N12)->get() == ISD::SETEQ) {
01484       N2 = N.getOperand(2);
01485       if (N2.getOpcode() == ISD::BasicBlock &&
01486           N10.Val->getValueType(0) == MVT::f64) {
01487         Select(Tmp0, N10);
01488         Select(Tmp1, N11);
01489         Tmp2 = SDOperand(CurDAG->getTargetNode(Alpha::CMPTEQ, MVT::f64, Tmp0, Tmp1), 0);
01490         Select(Tmp3, N2);
01491         Select(Chain, Chain);
01492         ResNode = CurDAG->getTargetNode(Alpha::FBNE, MVT::Other, Tmp2, Tmp3, Chain);
01493         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01494         Result = SDOperand(ResNode, N.ResNo);
01495         return;
01496       }
01497     }
01498 
01499     // Pattern: (brcond:void (setcc:i64 F8RC:f64:$RA, F8RC:f64:$RB, SETLT:Other), (bb:Other):$DISP)
01500     // Emits: (FBNE:void (CMPTLT:f64 F8RC:f64:$RA, F8RC:f64:$RB), (bb:Other):$DISP)
01501     // Pattern complexity = 4  cost = 2
01502     if (cast<CondCodeSDNode>(N12)->get() == ISD::SETLT) {
01503       N2 = N.getOperand(2);
01504       if (N2.getOpcode() == ISD::BasicBlock &&
01505           N10.Val->getValueType(0) == MVT::f64) {
01506         Select(Tmp0, N10);
01507         Select(Tmp1, N11);
01508         Tmp2 = SDOperand(CurDAG->getTargetNode(Alpha::CMPTLT, MVT::f64, Tmp0, Tmp1), 0);
01509         Select(Tmp3, N2);
01510         Select(Chain, Chain);
01511         ResNode = CurDAG->getTargetNode(Alpha::FBNE, MVT::Other, Tmp2, Tmp3, Chain);
01512         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01513         Result = SDOperand(ResNode, N.ResNo);
01514         return;
01515       }
01516     }
01517 
01518     // Pattern: (brcond:void (setcc:i64 F8RC:f64:$RA, F8RC:f64:$RB, SETLE:Other), (bb:Other):$DISP)
01519     // Emits: (FBNE:void (CMPTLE:f64 F8RC:f64:$RA, F8RC:f64:$RB), (bb:Other):$DISP)
01520     // Pattern complexity = 4  cost = 2
01521     if (cast<CondCodeSDNode>(N12)->get() == ISD::SETLE) {
01522       N2 = N.getOperand(2);
01523       if (N2.getOpcode() == ISD::BasicBlock &&
01524           N10.Val->getValueType(0) == MVT::f64) {
01525         Select(Tmp0, N10);
01526         Select(Tmp1, N11);
01527         Tmp2 = SDOperand(CurDAG->getTargetNode(Alpha::CMPTLE, MVT::f64, Tmp0, Tmp1), 0);
01528         Select(Tmp3, N2);
01529         Select(Chain, Chain);
01530         ResNode = CurDAG->getTargetNode(Alpha::FBNE, MVT::Other, Tmp2, Tmp3, Chain);
01531         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01532         Result = SDOperand(ResNode, N.ResNo);
01533         return;
01534       }
01535     }
01536 
01537     // Pattern: (brcond:void (setcc:i64 F8RC:f64:$RA, F8RC:f64:$RB, SETGT:Other), (bb:Other):$DISP)
01538     // Emits: (FBNE:void (CMPTLT:f64 F8RC:f64:$RB, F8RC:f64:$RA), (bb:Other):$DISP)
01539     // Pattern complexity = 4  cost = 2
01540     if (cast<CondCodeSDNode>(N12)->get() == ISD::SETGT) {
01541       N2 = N.getOperand(2);
01542       if (N2.getOpcode() == ISD::BasicBlock &&
01543           N10.Val->getValueType(0) == MVT::f64) {
01544         Select(Tmp0, N11);
01545         Select(Tmp1, N10);
01546         Tmp2 = SDOperand(CurDAG->getTargetNode(Alpha::CMPTLT, MVT::f64, Tmp0, Tmp1), 0);
01547         Select(Tmp3, N2);
01548         Select(Chain, Chain);
01549         ResNode = CurDAG->getTargetNode(Alpha::FBNE, MVT::Other, Tmp2, Tmp3, Chain);
01550         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01551         Result = SDOperand(ResNode, N.ResNo);
01552         return;
01553       }
01554     }
01555 
01556     // Pattern: (brcond:void (setcc:i64 F8RC:f64:$RA, F8RC:f64:$RB, SETGE:Other), (bb:Other):$DISP)
01557     // Emits: (FBNE:void (CMPTLE:f64 F8RC:f64:$RB, F8RC:f64:$RA), (bb:Other):$DISP)
01558     // Pattern complexity = 4  cost = 2
01559     if (cast<CondCodeSDNode>(N12)->get() == ISD::SETGE) {
01560       N2 = N.getOperand(2);
01561       if (N2.getOpcode() == ISD::BasicBlock &&
01562           N10.Val->getValueType(0) == MVT::f64) {
01563         Select(Tmp0, N11);
01564         Select(Tmp1, N10);
01565         Tmp2 = SDOperand(CurDAG->getTargetNode(Alpha::CMPTLE, MVT::f64, Tmp0, Tmp1), 0);
01566         Select(Tmp3, N2);
01567         Select(Chain, Chain);
01568         ResNode = CurDAG->getTargetNode(Alpha::FBNE, MVT::Other, Tmp2, Tmp3, Chain);
01569         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01570         Result = SDOperand(ResNode, N.ResNo);
01571         return;
01572       }
01573     }
01574 
01575     // Pattern: (brcond:void (setcc:i64 F8RC:f64:$RA, F8RC:f64:$RB, SETNE:Other), (bb:Other):$DISP)
01576     // Emits: (FBEQ:void (CMPTEQ:f64 F8RC:f64:$RA, F8RC:f64:$RB), (bb:Other):$DISP)
01577     // Pattern complexity = 4  cost = 2
01578     if (cast<CondCodeSDNode>(N12)->get() == ISD::SETNE) {
01579       N2 = N.getOperand(2);
01580       if (N2.getOpcode() == ISD::BasicBlock &&
01581           N10.Val->getValueType(0) == MVT::f64) {
01582         Select(Tmp0, N10);
01583         Select(Tmp1, N11);
01584         Tmp2 = SDOperand(CurDAG->getTargetNode(Alpha::CMPTEQ, MVT::f64, Tmp0, Tmp1), 0);
01585         Select(Tmp3, N2);
01586         Select(Chain, Chain);
01587         ResNode = CurDAG->getTargetNode(Alpha::FBEQ, MVT::Other, Tmp2, Tmp3, Chain);
01588         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01589         Result = SDOperand(ResNode, N.ResNo);
01590         return;
01591       }
01592     }
01593   }
01594 
01595   // Pattern: (brcond:void GPRC:i64:$RA, (bb:Other):$DISP)
01596   // Emits: (BNE:void GPRC:i64:$RA, (bb:Other):$DISP)
01597   // Pattern complexity = 2  cost = 1
01598   N2 = N.getOperand(2);
01599   if (N2.getOpcode() == ISD::BasicBlock) {
01600     Select(Tmp0, N1);
01601     Select(Tmp1, N2);
01602     Select(Chain, Chain);
01603     ResNode = CurDAG->getTargetNode(Alpha::BNE, MVT::Other, Tmp0, Tmp1, Chain);
01604     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01605     Result = SDOperand(ResNode, N.ResNo);
01606     return;
01607   }
01608   std::cerr << "Cannot yet select: ";
01609   N.Val->dump(CurDAG);
01610   std::cerr << '\n';
01611   abort();
01612 }
01613 
01614 void Select_callseq_end(SDOperand &Result, SDOperand N) {
01615   SDOperand Chain(0, 0);
01616   SDOperand N1(0, 0);
01617   SDOperand Tmp0(0, 0);
01618   SDNode *ResNode;
01619   Chain = N.getOperand(0);
01620   N1 = N.getOperand(1);
01621   if (N1.getOpcode() == ISD::Constant) {
01622     uint64_t Tmp0C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
01623     Tmp0 = CurDAG->getTargetConstant(Tmp0C, MVT::i64);
01624     Select(Chain, Chain);
01625     ResNode = CurDAG->getTargetNode(Alpha::ADJUSTSTACKDOWN, MVT::Other, Tmp0, Chain);
01626     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01627     Result = SDOperand(ResNode, N.ResNo);
01628     return;
01629   }
01630   std::cerr << "Cannot yet select: ";
01631   N.Val->dump(CurDAG);
01632   std::cerr << '\n';
01633   abort();
01634 }
01635 
01636 void Select_callseq_start(SDOperand &Result, SDOperand N) {
01637   SDOperand Chain(0, 0);
01638   SDOperand N1(0, 0);
01639   SDOperand Tmp0(0, 0);
01640   SDNode *ResNode;
01641   Chain = N.getOperand(0);
01642   N1 = N.getOperand(1);
01643   if (N1.getOpcode() == ISD::Constant) {
01644     uint64_t Tmp0C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
01645     Tmp0 = CurDAG->getTargetConstant(Tmp0C, MVT::i64);
01646     Select(Chain, Chain);
01647     ResNode = CurDAG->getTargetNode(Alpha::ADJUSTSTACKUP, MVT::Other, Tmp0, Chain);
01648     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01649     Result = SDOperand(ResNode, N.ResNo);
01650     return;
01651   }
01652   std::cerr << "Cannot yet select: ";
01653   N.Val->dump(CurDAG);
01654   std::cerr << '\n';
01655   abort();
01656 }
01657 
01658 void Select_ctlz(SDOperand &Result, SDOperand N) {
01659   SDOperand N0(0, 0);
01660   SDOperand Tmp0(0, 0);
01661   SDNode *ResNode;
01662   N0 = N.getOperand(0);
01663   Select(Tmp0, N0);
01664   if (N.Val->hasOneUse()) {
01665     Result = CurDAG->SelectNodeTo(N.Val, Alpha::CTLZ, MVT::i64, Tmp0);
01666   } else {
01667     ResNode = CurDAG->getTargetNode(Alpha::CTLZ, MVT::i64, Tmp0);
01668     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
01669     Result = SDOperand(ResNode, 0);
01670   }
01671   return;
01672 }
01673 
01674 void Select_ctpop(SDOperand &Result, SDOperand N) {
01675   SDOperand N0(0, 0);
01676   SDOperand Tmp0(0, 0);
01677   SDNode *ResNode;
01678   N0 = N.getOperand(0);
01679   Select(Tmp0, N0);
01680   if (N.Val->hasOneUse()) {
01681     Result = CurDAG->SelectNodeTo(N.Val, Alpha::CTPOP, MVT::i64, Tmp0);
01682   } else {
01683     ResNode = CurDAG->getTargetNode(Alpha::CTPOP, MVT::i64, Tmp0);
01684     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
01685     Result = SDOperand(ResNode, 0);
01686   }
01687   return;
01688 }
01689 
01690 void Select_cttz(SDOperand &Result, SDOperand N) {
01691   SDOperand N0(0, 0);
01692   SDOperand Tmp0(0, 0);
01693   SDNode *ResNode;
01694   N0 = N.getOperand(0);
01695   Select(Tmp0, N0);
01696   if (N.Val->hasOneUse()) {
01697     Result = CurDAG->SelectNodeTo(N.Val, Alpha::CTTZ, MVT::i64, Tmp0);
01698   } else {
01699     ResNode = CurDAG->getTargetNode(Alpha::CTTZ, MVT::i64, Tmp0);
01700     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
01701     Result = SDOperand(ResNode, 0);
01702   }
01703   return;
01704 }
01705 
01706 void Select_extld(SDOperand &Result, SDOperand N) {
01707   if (N.ResNo == 1 && N.getValue(0).hasOneUse()) {
01708     SDOperand Dummy = CurDAG->getNode(ISD::HANDLENODE, MVT::Other, N);
01709     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, Dummy.Val, 0);
01710     SelectionDAG::InsertISelMapEntry(HandleMap, N.Val, 1, Dummy.Val, 0);
01711     Result = Dummy;
01712     return;
01713   }
01714   SDOperand Chain(0, 0);
01715   SDOperand N1(0, 0);
01716   SDOperand N10(0, 0);
01717   SDOperand N11(0, 0);
01718   SDOperand N2(0, 0);
01719   SDOperand N3(0, 0);
01720   SDOperand Tmp0(0, 0);
01721   SDOperand Tmp1(0, 0);
01722   SDNode *ResNode;
01723   Chain = N.getOperand(0);
01724   N1 = N.getOperand(1);
01725   if (N1.getOpcode() == ISD::ADD) {
01726     N10 = N1.getOperand(0);
01727     N11 = N1.getOperand(1);
01728     if (N11.getOpcode() == ISD::Constant &&
01729         Predicate_immSExt16(N11.Val)) {
01730       N2 = N.getOperand(2);
01731       N3 = N.getOperand(3);
01732 
01733       // Pattern: (extld:i64 (add:i64 GPRC:i64:$RB, (imm:i64)<<P:Predicate_immSExt16>>:$DISP), srcvalue:Other:$dummy, i8:Other)
01734       // Emits: (LDBU:i64 (imm:i64)<<P:Predicate_immSExt16>>:$DISP, GPRC:i64:$RB)
01735       // Pattern complexity = 7  cost = 1
01736       if (cast<VTSDNode>(N3)->getVT() == MVT::i8 &&
01737           N.Val->getValueType(0) == MVT::i64) {
01738         uint64_t Tmp0C = (uint64_t)cast<ConstantSDNode>(N11)->getValue();
01739         Tmp0 = CurDAG->getTargetConstant(Tmp0C, MVT::i64);
01740         Select(Tmp1, N10);
01741         Select(Chain, Chain);
01742         ResNode = CurDAG->getTargetNode(Alpha::LDBU, MVT::i64, MVT::Other, Tmp0, Tmp1, Chain);
01743         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01744         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
01745         if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
01746         Result = SDOperand(ResNode, N.ResNo);
01747         return;
01748       }
01749 
01750       // Pattern: (extld:i64 (add:i64 GPRC:i64:$RB, (imm:i64)<<P:Predicate_immSExt16>>:$DISP), srcvalue:Other:$dummy, i16:Other)
01751       // Emits: (LDWU:i64 (imm:i64)<<P:Predicate_immSExt16>>:$DISP, GPRC:i64:$RB)
01752       // Pattern complexity = 7  cost = 1
01753       if (cast<VTSDNode>(N3)->getVT() == MVT::i16 &&
01754           N.Val->getValueType(0) == MVT::i64) {
01755         uint64_t Tmp0C = (uint64_t)cast<ConstantSDNode>(N11)->getValue();
01756         Tmp0 = CurDAG->getTargetConstant(Tmp0C, MVT::i64);
01757         Select(Tmp1, N10);
01758         Select(Chain, Chain);
01759         ResNode = CurDAG->getTargetNode(Alpha::LDWU, MVT::i64, MVT::Other, Tmp0, Tmp1, Chain);
01760         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01761         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
01762         if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
01763         Result = SDOperand(ResNode, N.ResNo);
01764         return;
01765       }
01766 
01767       // Pattern: (extld:i64 (add:i64 GPRC:i64:$RB, (imm:i64)<<P:Predicate_immSExt16>>:$DISP), srcvalue:Other:$dummy, i32:Other)
01768       // Emits: (LDL:i64 (imm:i64)<<P:Predicate_immSExt16>>:$DISP, GPRC:i64:$RB)
01769       // Pattern complexity = 7  cost = 1
01770       if (cast<VTSDNode>(N3)->getVT() == MVT::i32 &&
01771           N.Val->getValueType(0) == MVT::i64) {
01772         uint64_t Tmp0C = (uint64_t)cast<ConstantSDNode>(N11)->getValue();
01773         Tmp0 = CurDAG->getTargetConstant(Tmp0C, MVT::i64);
01774         Select(Tmp1, N10);
01775         Select(Chain, Chain);
01776         ResNode = CurDAG->getTargetNode(Alpha::LDL, MVT::i64, MVT::Other, Tmp0, Tmp1, Chain);
01777         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01778         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
01779         if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
01780         Result = SDOperand(ResNode, N.ResNo);
01781         return;
01782       }
01783     }
01784   }
01785   N2 = N.getOperand(2);
01786   N3 = N.getOperand(3);
01787 
01788   // Pattern: (extld:i64 GPRC:i64:$addr, srcvalue:Other:$dummy, i8:Other)
01789   // Emits: (LDBU:i64 0:i64, GPRC:i64:$addr)
01790   // Pattern complexity = 2  cost = 1
01791   if (cast<VTSDNode>(N3)->getVT() == MVT::i8 &&
01792       N.Val->getValueType(0) == MVT::i64) {
01793     Tmp0 = CurDAG->getTargetConstant(0, MVT::i64);
01794     Select(Tmp1, N1);
01795     Select(Chain, Chain);
01796     ResNode = CurDAG->getTargetNode(Alpha::LDBU, MVT::i64, MVT::Other, Tmp0, Tmp1, Chain);
01797     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01798     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
01799     if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
01800     Result = SDOperand(ResNode, N.ResNo);
01801     return;
01802   }
01803 
01804   // Pattern: (extld:i64 GPRC:i64:$addr, srcvalue:Other:$dummy, i16:Other)
01805   // Emits: (LDWU:i64 0:i64, GPRC:i64:$addr)
01806   // Pattern complexity = 2  cost = 1
01807   if (cast<VTSDNode>(N3)->getVT() == MVT::i16 &&
01808       N.Val->getValueType(0) == MVT::i64) {
01809     Tmp0 = CurDAG->getTargetConstant(0, MVT::i64);
01810     Select(Tmp1, N1);
01811     Select(Chain, Chain);
01812     ResNode = CurDAG->getTargetNode(Alpha::LDWU, MVT::i64, MVT::Other, Tmp0, Tmp1, Chain);
01813     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01814     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
01815     if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
01816     Result = SDOperand(ResNode, N.ResNo);
01817     return;
01818   }
01819 
01820   // Pattern: (extld:i64 GPRC:i64:$addr, srcvalue:Other:$dummy, i32:Other)
01821   // Emits: (LDL:i64 0:i64, GPRC:i64:$addr)
01822   // Pattern complexity = 2  cost = 1
01823   if (cast<VTSDNode>(N3)->getVT() == MVT::i32 &&
01824       N.Val->getValueType(0) == MVT::i64) {
01825     Tmp0 = CurDAG->getTargetConstant(0, MVT::i64);
01826     Select(Tmp1, N1);
01827     Select(Chain, Chain);
01828     ResNode = CurDAG->getTargetNode(Alpha::LDL, MVT::i64, MVT::Other, Tmp0, Tmp1, Chain);
01829     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
01830     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
01831     if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
01832     Result = SDOperand(ResNode, N.ResNo);
01833     return;
01834   }
01835   std::cerr << "Cannot yet select: ";
01836   N.Val->dump(CurDAG);
01837   std::cerr << '\n';
01838   abort();
01839 }
01840 
01841 void Select_fabs(SDOperand &Result, SDOperand N) {
01842   SDOperand N0(0, 0);
01843   SDOperand Tmp0(0, 0);
01844   SDOperand Tmp1(0, 0);
01845   SDNode *ResNode;
01846   N0 = N.getOperand(0);
01847 
01848   // Pattern: (fabs:f64 F8RC:f64:$RB)
01849   // Emits: (CPYST:f64 F31:f64, F8RC:f64:$RB)
01850   // Pattern complexity = 2  cost = 1
01851   if (N.Val->getValueType(0) == MVT::f64) {
01852     Tmp0 = CurDAG->getRegister(Alpha::F31, MVT::f64);
01853     Select(Tmp1, N0);
01854     if (N.Val->hasOneUse()) {
01855       Result = CurDAG->SelectNodeTo(N.Val, Alpha::CPYST, MVT::f64, Tmp0, Tmp1);
01856     } else {
01857       ResNode = CurDAG->getTargetNode(Alpha::CPYST, MVT::f64, Tmp0, Tmp1);
01858       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
01859       Result = SDOperand(ResNode, 0);
01860     }
01861     return;
01862   }
01863 
01864   // Pattern: (fabs:f32 F4RC:f32:$RB)
01865   // Emits: (CPYSS:f32 F31:f32, F4RC:f32:$RB)
01866   // Pattern complexity = 2  cost = 1
01867   if (N.Val->getValueType(0) == MVT::f32) {
01868     Tmp0 = CurDAG->getRegister(Alpha::F31, MVT::f32);
01869     Select(Tmp1, N0);
01870     if (N.Val->hasOneUse()) {
01871       Result = CurDAG->SelectNodeTo(N.Val, Alpha::CPYSS, MVT::f32, Tmp0, Tmp1);
01872     } else {
01873       ResNode = CurDAG->getTargetNode(Alpha::CPYSS, MVT::f32, Tmp0, Tmp1);
01874       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
01875       Result = SDOperand(ResNode, 0);
01876     }
01877     return;
01878   }
01879   std::cerr << "Cannot yet select: ";
01880   N.Val->dump(CurDAG);
01881   std::cerr << '\n';
01882   abort();
01883 }
01884 
01885 void Select_fadd(SDOperand &Result, SDOperand N) {
01886   SDOperand N0(0, 0);
01887   SDOperand N1(0, 0);
01888   SDOperand Tmp0(0, 0);
01889   SDOperand Tmp1(0, 0);
01890   SDNode *ResNode;
01891   N0 = N.getOperand(0);
01892   N1 = N.getOperand(1);
01893 
01894   // Pattern: (fadd:f32 F4RC:f32:$RA, F4RC:f32:$RB)
01895   // Emits: (ADDS:f32 F4RC:f32:$RA, F4RC:f32:$RB)
01896   // Pattern complexity = 2  cost = 1
01897   if (N.Val->getValueType(0) == MVT::f32) {
01898     Select(Tmp0, N0);
01899     Select(Tmp1, N1);
01900     if (N.Val->hasOneUse()) {
01901       Result = CurDAG->SelectNodeTo(N.Val, Alpha::ADDS, MVT::f32, Tmp0, Tmp1);
01902     } else {
01903       ResNode = CurDAG->getTargetNode(Alpha::ADDS, MVT::f32, Tmp0, Tmp1);
01904       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
01905       Result = SDOperand(ResNode, 0);
01906     }
01907     return;
01908   }
01909 
01910   // Pattern: (fadd:f64 F8RC:f64:$RA, F8RC:f64:$RB)
01911   // Emits: (ADDT:f64 F8RC:f64:$RA, F8RC:f64:$RB)
01912   // Pattern complexity = 2  cost = 1
01913   if (N.Val->getValueType(0) == MVT::f64) {
01914     Select(Tmp0, N0);
01915     Select(Tmp1, N1);
01916     if (N.Val->hasOneUse()) {
01917       Result = CurDAG->SelectNodeTo(N.Val, Alpha::ADDT, MVT::f64, Tmp0, Tmp1);
01918     } else {
01919       ResNode = CurDAG->getTargetNode(Alpha::ADDT, MVT::f64, Tmp0, Tmp1);
01920       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
01921       Result = SDOperand(ResNode, 0);
01922     }
01923     return;
01924   }
01925   std::cerr << "Cannot yet select: ";
01926   N.Val->dump(CurDAG);
01927   std::cerr << '\n';
01928   abort();
01929 }
01930 
01931 void Select_fcopysign(SDOperand &Result, SDOperand N) {
01932   SDOperand N0(0, 0);
01933   SDOperand N1(0, 0);
01934   SDOperand N10(0, 0);
01935   SDOperand Tmp0(0, 0);
01936   SDOperand Tmp1(0, 0);
01937   SDNode *ResNode;
01938   N0 = N.getOperand(0);
01939   N1 = N.getOperand(1);
01940   if (N1.getOpcode() == ISD::FNEG) {
01941     N10 = N1.getOperand(0);
01942 
01943     // Pattern: (fcopysign:f32 F4RC:f32:$A, (fneg:f32 F4RC:f32:$B))
01944     // Emits: (CPYSNS:f32 F4RC:f32:$B, F4RC:f32:$A)
01945     // Pattern complexity = 4  cost = 1
01946     if (N.Val->getValueType(0) == MVT::f32 &&
01947         N1.Val->getValueType(0) == MVT::f32) {
01948       Select(Tmp0, N10);
01949       Select(Tmp1, N0);
01950       if (N.Val->hasOneUse()) {
01951         Result = CurDAG->SelectNodeTo(N.Val, Alpha::CPYSNS, MVT::f32, Tmp0, Tmp1);
01952       } else {
01953         ResNode = CurDAG->getTargetNode(Alpha::CPYSNS, MVT::f32, Tmp0, Tmp1);
01954         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
01955         Result = SDOperand(ResNode, 0);
01956       }
01957       return;
01958     }
01959 
01960     // Pattern: (fcopysign:f64 F8RC:f64:$A, (fneg:f64 F8RC:f64:$B))
01961     // Emits: (CPYSNT:f64 F8RC:f64:$B, F8RC:f64:$A)
01962     // Pattern complexity = 4  cost = 1
01963     if (N.Val->getValueType(0) == MVT::f64 &&
01964         N1.Val->getValueType(0) == MVT::f64) {
01965       Select(Tmp0, N10);
01966       Select(Tmp1, N0);
01967       if (N.Val->hasOneUse()) {
01968         Result = CurDAG->SelectNodeTo(N.Val, Alpha::CPYSNT, MVT::f64, Tmp0, Tmp1);
01969       } else {
01970         ResNode = CurDAG->getTargetNode(Alpha::CPYSNT, MVT::f64, Tmp0, Tmp1);
01971         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
01972         Result = SDOperand(ResNode, 0);
01973       }
01974       return;
01975     }
01976 
01977     // Pattern: (fcopysign:f32 F4RC:f32:$A, (fneg:f64 F8RC:f64:$B))
01978     // Emits: (CPYSNSt:f32 F8RC:f64:$B, F4RC:f32:$A)
01979     // Pattern complexity = 4  cost = 1
01980     if (N.Val->getValueType(0) == MVT::f32 &&
01981         N1.Val->getValueType(0) == MVT::f64) {
01982       Select(Tmp0, N10);
01983       Select(Tmp1, N0);
01984       if (N.Val->hasOneUse()) {
01985         Result = CurDAG->SelectNodeTo(N.Val, Alpha::CPYSNSt, MVT::f32, Tmp0, Tmp1);
01986       } else {
01987         ResNode = CurDAG->getTargetNode(Alpha::CPYSNSt, MVT::f32, Tmp0, Tmp1);
01988         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
01989         Result = SDOperand(ResNode, 0);
01990       }
01991       return;
01992     }
01993 
01994     // Pattern: (fcopysign:f64 F8RC:f64:$A, (fneg:f32 F4RC:f32:$B))
01995     // Emits: (CPYSNTs:f64 F4RC:f32:$B, F8RC:f64:$A)
01996     // Pattern complexity = 4  cost = 1
01997     if (N.Val->getValueType(0) == MVT::f64 &&
01998         N1.Val->getValueType(0) == MVT::f32) {
01999       Select(Tmp0, N10);
02000       Select(Tmp1, N0);
02001       if (N.Val->hasOneUse()) {
02002         Result = CurDAG->SelectNodeTo(N.Val, Alpha::CPYSNTs, MVT::f64, Tmp0, Tmp1);
02003       } else {
02004         ResNode = CurDAG->getTargetNode(Alpha::CPYSNTs, MVT::f64, Tmp0, Tmp1);
02005         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02006         Result = SDOperand(ResNode, 0);
02007       }
02008       return;
02009     }
02010   }
02011 
02012   // Pattern: (fcopysign:f32 F4RC:f32:$RB, F4RC:f32:$RA)
02013   // Emits: (CPYSS:f32 F4RC:f32:$RA, F4RC:f32:$RB)
02014   // Pattern complexity = 2  cost = 1
02015   if (N.Val->getValueType(0) == MVT::f32 &&
02016       N1.Val->getValueType(0) == MVT::f32) {
02017     Select(Tmp0, N1);
02018     Select(Tmp1, N0);
02019     if (N.Val->hasOneUse()) {
02020       Result = CurDAG->SelectNodeTo(N.Val, Alpha::CPYSS, MVT::f32, Tmp0, Tmp1);
02021     } else {
02022       ResNode = CurDAG->getTargetNode(Alpha::CPYSS, MVT::f32, Tmp0, Tmp1);
02023       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02024       Result = SDOperand(ResNode, 0);
02025     }
02026     return;
02027   }
02028   if (N.Val->getValueType(0) == MVT::f64) {
02029 
02030     // Pattern: (fcopysign:f64 F8RC:f64:$RB, F8RC:f64:$RA)
02031     // Emits: (CPYST:f64 F8RC:f64:$RA, F8RC:f64:$RB)
02032     // Pattern complexity = 2  cost = 1
02033     if (N1.Val->getValueType(0) == MVT::f64) {
02034       Select(Tmp0, N1);
02035       Select(Tmp1, N0);
02036       if (N.Val->hasOneUse()) {
02037         Result = CurDAG->SelectNodeTo(N.Val, Alpha::CPYST, MVT::f64, Tmp0, Tmp1);
02038       } else {
02039         ResNode = CurDAG->getTargetNode(Alpha::CPYST, MVT::f64, Tmp0, Tmp1);
02040         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02041         Result = SDOperand(ResNode, 0);
02042       }
02043       return;
02044     }
02045 
02046     // Pattern: (fcopysign:f64 F8RC:f64:$RB, F4RC:f32:$RA)
02047     // Emits: (CPYSTs:f64 F4RC:f32:$RA, F8RC:f64:$RB)
02048     // Pattern complexity = 2  cost = 1
02049     if (N1.Val->getValueType(0) == MVT::f32) {
02050       Select(Tmp0, N1);
02051       Select(Tmp1, N0);
02052       if (N.Val->hasOneUse()) {
02053         Result = CurDAG->SelectNodeTo(N.Val, Alpha::CPYSTs, MVT::f64, Tmp0, Tmp1);
02054       } else {
02055         ResNode = CurDAG->getTargetNode(Alpha::CPYSTs, MVT::f64, Tmp0, Tmp1);
02056         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02057         Result = SDOperand(ResNode, 0);
02058       }
02059       return;
02060     }
02061   }
02062 
02063   // Pattern: (fcopysign:f32 F4RC:f32:$RB, F8RC:f64:$RA)
02064   // Emits: (CPYSSt:f32 F8RC:f64:$RA, F4RC:f32:$RB)
02065   // Pattern complexity = 2  cost = 1
02066   if (N.Val->getValueType(0) == MVT::f32 &&
02067       N1.Val->getValueType(0) == MVT::f64) {
02068     Select(Tmp0, N1);
02069     Select(Tmp1, N0);
02070     if (N.Val->hasOneUse()) {
02071       Result = CurDAG->SelectNodeTo(N.Val, Alpha::CPYSSt, MVT::f32, Tmp0, Tmp1);
02072     } else {
02073       ResNode = CurDAG->getTargetNode(Alpha::CPYSSt, MVT::f32, Tmp0, Tmp1);
02074       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02075       Result = SDOperand(ResNode, 0);
02076     }
02077     return;
02078   }
02079   std::cerr << "Cannot yet select: ";
02080   N.Val->dump(CurDAG);
02081   std::cerr << '\n';
02082   abort();
02083 }
02084 
02085 void Select_fdiv(SDOperand &Result, SDOperand N) {
02086   SDOperand N0(0, 0);
02087   SDOperand N1(0, 0);
02088   SDOperand Tmp0(0, 0);
02089   SDOperand Tmp1(0, 0);
02090   SDNode *ResNode;
02091   N0 = N.getOperand(0);
02092   N1 = N.getOperand(1);
02093 
02094   // Pattern: (fdiv:f32 F4RC:f32:$RA, F4RC:f32:$RB)
02095   // Emits: (DIVS:f32 F4RC:f32:$RA, F4RC:f32:$RB)
02096   // Pattern complexity = 2  cost = 1
02097   if (N.Val->getValueType(0) == MVT::f32) {
02098     Select(Tmp0, N0);
02099     Select(Tmp1, N1);
02100     if (N.Val->hasOneUse()) {
02101       Result = CurDAG->SelectNodeTo(N.Val, Alpha::DIVS, MVT::f32, Tmp0, Tmp1);
02102     } else {
02103       ResNode = CurDAG->getTargetNode(Alpha::DIVS, MVT::f32, Tmp0, Tmp1);
02104       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02105       Result = SDOperand(ResNode, 0);
02106     }
02107     return;
02108   }
02109 
02110   // Pattern: (fdiv:f64 F8RC:f64:$RA, F8RC:f64:$RB)
02111   // Emits: (DIVT:f64 F8RC:f64:$RA, F8RC:f64:$RB)
02112   // Pattern complexity = 2  cost = 1
02113   if (N.Val->getValueType(0) == MVT::f64) {
02114     Select(Tmp0, N0);
02115     Select(Tmp1, N1);
02116     if (N.Val->hasOneUse()) {
02117       Result = CurDAG->SelectNodeTo(N.Val, Alpha::DIVT, MVT::f64, Tmp0, Tmp1);
02118     } else {
02119       ResNode = CurDAG->getTargetNode(Alpha::DIVT, MVT::f64, Tmp0, Tmp1);
02120       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02121       Result = SDOperand(ResNode, 0);
02122     }
02123     return;
02124   }
02125   std::cerr << "Cannot yet select: ";
02126   N.Val->dump(CurDAG);
02127   std::cerr << '\n';
02128   abort();
02129 }
02130 
02131 void Select_fextend(SDOperand &Result, SDOperand N) {
02132   SDOperand N0(0, 0);
02133   SDOperand Tmp0(0, 0);
02134   SDNode *ResNode;
02135   N0 = N.getOperand(0);
02136   Select(Tmp0, N0);
02137   if (N.Val->hasOneUse()) {
02138     Result = CurDAG->SelectNodeTo(N.Val, Alpha::CVTST, MVT::f64, Tmp0);
02139   } else {
02140     ResNode = CurDAG->getTargetNode(Alpha::CVTST, MVT::f64, Tmp0);
02141     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02142     Result = SDOperand(ResNode, 0);
02143   }
02144   return;
02145 }
02146 
02147 void Select_fmul(SDOperand &Result, SDOperand N) {
02148   SDOperand N0(0, 0);
02149   SDOperand N1(0, 0);
02150   SDOperand Tmp0(0, 0);
02151   SDOperand Tmp1(0, 0);
02152   SDNode *ResNode;
02153   N0 = N.getOperand(0);
02154   N1 = N.getOperand(1);
02155 
02156   // Pattern: (fmul:f32 F4RC:f32:$RA, F4RC:f32:$RB)
02157   // Emits: (MULS:f32 F4RC:f32:$RA, F4RC:f32:$RB)
02158   // Pattern complexity = 2  cost = 1
02159   if (N.Val->getValueType(0) == MVT::f32) {
02160     Select(Tmp0, N0);
02161     Select(Tmp1, N1);
02162     if (N.Val->hasOneUse()) {
02163       Result = CurDAG->SelectNodeTo(N.Val, Alpha::MULS, MVT::f32, Tmp0, Tmp1);
02164     } else {
02165       ResNode = CurDAG->getTargetNode(Alpha::MULS, MVT::f32, Tmp0, Tmp1);
02166       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02167       Result = SDOperand(ResNode, 0);
02168     }
02169     return;
02170   }
02171 
02172   // Pattern: (fmul:f64 F8RC:f64:$RA, F8RC:f64:$RB)
02173   // Emits: (MULT:f64 F8RC:f64:$RA, F8RC:f64:$RB)
02174   // Pattern complexity = 2  cost = 1
02175   if (N.Val->getValueType(0) == MVT::f64) {
02176     Select(Tmp0, N0);
02177     Select(Tmp1, N1);
02178     if (N.Val->hasOneUse()) {
02179       Result = CurDAG->SelectNodeTo(N.Val, Alpha::MULT, MVT::f64, Tmp0, Tmp1);
02180     } else {
02181       ResNode = CurDAG->getTargetNode(Alpha::MULT, MVT::f64, Tmp0, Tmp1);
02182       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02183       Result = SDOperand(ResNode, 0);
02184     }
02185     return;
02186   }
02187   std::cerr << "Cannot yet select: ";
02188   N.Val->dump(CurDAG);
02189   std::cerr << '\n';
02190   abort();
02191 }
02192 
02193 void Select_fneg(SDOperand &Result, SDOperand N) {
02194   SDOperand N0(0, 0);
02195   SDOperand N00(0, 0);
02196   SDOperand N01(0, 0);
02197   SDOperand Tmp0(0, 0);
02198   SDOperand Tmp1(0, 0);
02199   SDNode *ResNode;
02200   N0 = N.getOperand(0);
02201   if (N0.getOpcode() == ISD::FCOPYSIGN) {
02202     N00 = N0.getOperand(0);
02203     N01 = N0.getOperand(1);
02204 
02205     // Pattern: (fneg:f32 (fcopysign:f32 F4RC:f32:$RB, F4RC:f32:$RA))
02206     // Emits: (CPYSNS:f32 F4RC:f32:$RA, F4RC:f32:$RB)
02207     // Pattern complexity = 4  cost = 1
02208     if (N.Val->getValueType(0) == MVT::f32 &&
02209         N01.Val->getValueType(0) == MVT::f32) {
02210       Select(Tmp0, N01);
02211       Select(Tmp1, N00);
02212       if (N.Val->hasOneUse()) {
02213         Result = CurDAG->SelectNodeTo(N.Val, Alpha::CPYSNS, MVT::f32, Tmp0, Tmp1);
02214       } else {
02215         ResNode = CurDAG->getTargetNode(Alpha::CPYSNS, MVT::f32, Tmp0, Tmp1);
02216         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02217         Result = SDOperand(ResNode, 0);
02218       }
02219       return;
02220     }
02221     if (N.Val->getValueType(0) == MVT::f64) {
02222 
02223       // Pattern: (fneg:f64 (fcopysign:f64 F8RC:f64:$RB, F8RC:f64:$RA))
02224       // Emits: (CPYSNT:f64 F8RC:f64:$RA, F8RC:f64:$RB)
02225       // Pattern complexity = 4  cost = 1
02226       if (N01.Val->getValueType(0) == MVT::f64) {
02227         Select(Tmp0, N01);
02228         Select(Tmp1, N00);
02229         if (N.Val->hasOneUse()) {
02230           Result = CurDAG->SelectNodeTo(N.Val, Alpha::CPYSNT, MVT::f64, Tmp0, Tmp1);
02231         } else {
02232           ResNode = CurDAG->getTargetNode(Alpha::CPYSNT, MVT::f64, Tmp0, Tmp1);
02233           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02234           Result = SDOperand(ResNode, 0);
02235         }
02236         return;
02237       }
02238 
02239       // Pattern: (fneg:f64 (fcopysign:f64 F8RC:f64:$RB, F4RC:f32:$RA))
02240       // Emits: (CPYSNTs:f64 F4RC:f32:$RA, F8RC:f64:$RB)
02241       // Pattern complexity = 4  cost = 1
02242       if (N01.Val->getValueType(0) == MVT::f32) {
02243         Select(Tmp0, N01);
02244         Select(Tmp1, N00);
02245         if (N.Val->hasOneUse()) {
02246           Result = CurDAG->SelectNodeTo(N.Val, Alpha::CPYSNTs, MVT::f64, Tmp0, Tmp1);
02247         } else {
02248           ResNode = CurDAG->getTargetNode(Alpha::CPYSNTs, MVT::f64, Tmp0, Tmp1);
02249           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02250           Result = SDOperand(ResNode, 0);
02251         }
02252         return;
02253       }
02254     }
02255 
02256     // Pattern: (fneg:f32 (fcopysign:f32 F4RC:f32:$RB, F8RC:f64:$RA))
02257     // Emits: (CPYSNSt:f32 F8RC:f64:$RA, F4RC:f32:$RB)
02258     // Pattern complexity = 4  cost = 1
02259     if (N.Val->getValueType(0) == MVT::f32 &&
02260         N01.Val->getValueType(0) == MVT::f64) {
02261       Select(Tmp0, N01);
02262       Select(Tmp1, N00);
02263       if (N.Val->hasOneUse()) {
02264         Result = CurDAG->SelectNodeTo(N.Val, Alpha::CPYSNSt, MVT::f32, Tmp0, Tmp1);
02265       } else {
02266         ResNode = CurDAG->getTargetNode(Alpha::CPYSNSt, MVT::f32, Tmp0, Tmp1);
02267         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02268         Result = SDOperand(ResNode, 0);
02269       }
02270       return;
02271     }
02272   }
02273 
02274   // Pattern: (fneg:f64 F8RC:f64:$RB)
02275   // Emits: (CPYSNT:f64 F8RC:f64:$RB, F8RC:f64:$RB)
02276   // Pattern complexity = 2  cost = 1
02277   if (N.Val->getValueType(0) == MVT::f64) {
02278     Select(Tmp0, N0);
02279     if (N.Val->hasOneUse()) {
02280       Result = CurDAG->SelectNodeTo(N.Val, Alpha::CPYSNT, MVT::f64, Tmp0, Tmp0);
02281     } else {
02282       ResNode = CurDAG->getTargetNode(Alpha::CPYSNT, MVT::f64, Tmp0, Tmp0);
02283       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02284       Result = SDOperand(ResNode, 0);
02285     }
02286     return;
02287   }
02288 
02289   // Pattern: (fneg:f32 F4RC:f32:$RB)
02290   // Emits: (CPYSNS:f32 F4RC:f32:$RB, F4RC:f32:$RB)
02291   // Pattern complexity = 2  cost = 1
02292   if (N.Val->getValueType(0) == MVT::f32) {
02293     Select(Tmp0, N0);
02294     if (N.Val->hasOneUse()) {
02295       Result = CurDAG->SelectNodeTo(N.Val, Alpha::CPYSNS, MVT::f32, Tmp0, Tmp0);
02296     } else {
02297       ResNode = CurDAG->getTargetNode(Alpha::CPYSNS, MVT::f32, Tmp0, Tmp0);
02298       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02299       Result = SDOperand(ResNode, 0);
02300     }
02301     return;
02302   }
02303   std::cerr << "Cannot yet select: ";
02304   N.Val->dump(CurDAG);
02305   std::cerr << '\n';
02306   abort();
02307 }
02308 
02309 void Select_fround(SDOperand &Result, SDOperand N) {
02310   SDOperand N0(0, 0);
02311   SDOperand Tmp0(0, 0);
02312   SDNode *ResNode;
02313   N0 = N.getOperand(0);
02314   Select(Tmp0, N0);
02315   if (N.Val->hasOneUse()) {
02316     Result = CurDAG->SelectNodeTo(N.Val, Alpha::CVTTS, MVT::f32, Tmp0);
02317   } else {
02318     ResNode = CurDAG->getTargetNode(Alpha::CVTTS, MVT::f32, Tmp0);
02319     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02320     Result = SDOperand(ResNode, 0);
02321   }
02322   return;
02323 }
02324 
02325 void Select_fsqrt(SDOperand &Result, SDOperand N) {
02326   SDOperand N0(0, 0);
02327   SDOperand Tmp0(0, 0);
02328   SDNode *ResNode;
02329   N0 = N.getOperand(0);
02330 
02331   // Pattern: (fsqrt:f32 F4RC:f32:$RB)
02332   // Emits: (SQRTS:f32 F4RC:f32:$RB)
02333   // Pattern complexity = 2  cost = 1
02334   if (N.Val->getValueType(0) == MVT::f32) {
02335     Select(Tmp0, N0);
02336     if (N.Val->hasOneUse()) {
02337       Result = CurDAG->SelectNodeTo(N.Val, Alpha::SQRTS, MVT::f32, Tmp0);
02338     } else {
02339       ResNode = CurDAG->getTargetNode(Alpha::SQRTS, MVT::f32, Tmp0);
02340       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02341       Result = SDOperand(ResNode, 0);
02342     }
02343     return;
02344   }
02345 
02346   // Pattern: (fsqrt:f64 F8RC:f64:$RB)
02347   // Emits: (SQRTT:f64 F8RC:f64:$RB)
02348   // Pattern complexity = 2  cost = 1
02349   if (N.Val->getValueType(0) == MVT::f64) {
02350     Select(Tmp0, N0);
02351     if (N.Val->hasOneUse()) {
02352       Result = CurDAG->SelectNodeTo(N.Val, Alpha::SQRTT, MVT::f64, Tmp0);
02353     } else {
02354       ResNode = CurDAG->getTargetNode(Alpha::SQRTT, MVT::f64, Tmp0);
02355       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02356       Result = SDOperand(ResNode, 0);
02357     }
02358     return;
02359   }
02360   std::cerr << "Cannot yet select: ";
02361   N.Val->dump(CurDAG);
02362   std::cerr << '\n';
02363   abort();
02364 }
02365 
02366 void Select_fsub(SDOperand &Result, SDOperand N) {
02367   SDOperand N0(0, 0);
02368   SDOperand N1(0, 0);
02369   SDOperand Tmp0(0, 0);
02370   SDOperand Tmp1(0, 0);
02371   SDNode *ResNode;
02372   N0 = N.getOperand(0);
02373   N1 = N.getOperand(1);
02374 
02375   // Pattern: (fsub:f32 F4RC:f32:$RA, F4RC:f32:$RB)
02376   // Emits: (SUBS:f32 F4RC:f32:$RA, F4RC:f32:$RB)
02377   // Pattern complexity = 2  cost = 1
02378   if (N.Val->getValueType(0) == MVT::f32) {
02379     Select(Tmp0, N0);
02380     Select(Tmp1, N1);
02381     if (N.Val->hasOneUse()) {
02382       Result = CurDAG->SelectNodeTo(N.Val, Alpha::SUBS, MVT::f32, Tmp0, Tmp1);
02383     } else {
02384       ResNode = CurDAG->getTargetNode(Alpha::SUBS, MVT::f32, Tmp0, Tmp1);
02385       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02386       Result = SDOperand(ResNode, 0);
02387     }
02388     return;
02389   }
02390 
02391   // Pattern: (fsub:f64 F8RC:f64:$RA, F8RC:f64:$RB)
02392   // Emits: (SUBT:f64 F8RC:f64:$RA, F8RC:f64:$RB)
02393   // Pattern complexity = 2  cost = 1
02394   if (N.Val->getValueType(0) == MVT::f64) {
02395     Select(Tmp0, N0);
02396     Select(Tmp1, N1);
02397     if (N.Val->hasOneUse()) {
02398       Result = CurDAG->SelectNodeTo(N.Val, Alpha::SUBT, MVT::f64, Tmp0, Tmp1);
02399     } else {
02400       ResNode = CurDAG->getTargetNode(Alpha::SUBT, MVT::f64, Tmp0, Tmp1);
02401       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02402       Result = SDOperand(ResNode, 0);
02403     }
02404     return;
02405   }
02406   std::cerr << "Cannot yet select: ";
02407   N.Val->dump(CurDAG);
02408   std::cerr << '\n';
02409   abort();
02410 }
02411 
02412 void Select_imm(SDOperand &Result, SDOperand N) {
02413   SDOperand Tmp0(0, 0);
02414   SDOperand Tmp1(0, 0);
02415   SDOperand Tmp2(0, 0);
02416   SDOperand Tmp3(0, 0);
02417   SDOperand Tmp4(0, 0);
02418   SDOperand Tmp5(0, 0);
02419   SDOperand Tmp6(0, 0);
02420   SDOperand Tmp7(0, 0);
02421   SDOperand Tmp8(0, 0);
02422   SDNode *ResNode;
02423 
02424   // Pattern: (imm:i64)<<P:Predicate_immSExt16>>:$imm
02425   // Emits: (LDA:i64 (imm:i64)<<P:Predicate_immSExt16>>:$imm, R31:i64)
02426   // Pattern complexity = 3  cost = 1
02427   if (Predicate_immSExt16(N.Val)) {
02428     uint64_t Tmp0C = (uint64_t)cast<ConstantSDNode>(N)->getValue();
02429     Tmp0 = CurDAG->getTargetConstant(Tmp0C, MVT::i64);
02430     Tmp1 = CurDAG->getRegister(Alpha::R31, MVT::i64);
02431     if (N.Val->hasOneUse()) {
02432       Result = CurDAG->SelectNodeTo(N.Val, Alpha::LDA, MVT::i64, Tmp0, Tmp1);
02433     } else {
02434       ResNode = CurDAG->getTargetNode(Alpha::LDA, MVT::i64, Tmp0, Tmp1);
02435       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02436       Result = SDOperand(ResNode, 0);
02437     }
02438     return;
02439   }
02440 
02441   // Pattern: (imm:i64)<<P:Predicate_immConst2Part>>:$imm
02442   // Emits: (LDA:i64 (LL16:i64 (imm:i64)<<P:Predicate_immConst2Part>>:$imm), (LDAH:i64 (LH16:i64 (imm:i64)<<P:Predicate_immConst2Part>>:$imm), R31:i64))
02443   // Pattern complexity = 3  cost = 2
02444   if (Predicate_immConst2Part(N.Val)) {
02445     uint64_t Tmp0C = (uint64_t)cast<ConstantSDNode>(N)->getValue();
02446     Tmp0 = CurDAG->getTargetConstant(Tmp0C, MVT::i64);
02447     Tmp1 = Transform_LL16(Tmp0.Val);
02448     Tmp2 = Transform_LH16(Tmp0.Val);
02449     Tmp3 = CurDAG->getRegister(Alpha::R31, MVT::i64);
02450     Tmp4 = SDOperand(CurDAG->getTargetNode(Alpha::LDAH, MVT::i64, Tmp2, Tmp3), 0);
02451     if (N.Val->hasOneUse()) {
02452       Result = CurDAG->SelectNodeTo(N.Val, Alpha::LDA, MVT::i64, Tmp1, Tmp4);
02453     } else {
02454       ResNode = CurDAG->getTargetNode(Alpha::LDA, MVT::i64, Tmp1, Tmp4);
02455       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02456       Result = SDOperand(ResNode, 0);
02457     }
02458     return;
02459   }
02460 
02461   // Pattern: (imm:i64)<<P:Predicate_immSExt16int>><<X:SExt16>>:$imm
02462   // Emits: (ZAPNOTi:i64 (LDA:i64 (SExt16:i64 (imm:i64)<<P:Predicate_immSExt16int>><<X:SExt16>>:$imm), R31:i64), 15:i64)
02463   // Pattern complexity = 3  cost = 2
02464   if (Predicate_immSExt16int(N.Val)) {
02465     uint64_t Tmp0C = (uint64_t)cast<ConstantSDNode>(N)->getValue();
02466     Tmp0 = CurDAG->getTargetConstant(Tmp0C, MVT::i64);
02467     Tmp1 = Transform_SExt16(Tmp0.Val);
02468     Tmp2 = CurDAG->getRegister(Alpha::R31, MVT::i64);
02469     Tmp3 = SDOperand(CurDAG->getTargetNode(Alpha::LDA, MVT::i64, Tmp1, Tmp2), 0);
02470     Tmp4 = CurDAG->getTargetConstant(15, MVT::i64);
02471     if (N.Val->hasOneUse()) {
02472       Result = CurDAG->SelectNodeTo(N.Val, Alpha::ZAPNOTi, MVT::i64, Tmp3, Tmp4);
02473     } else {
02474       ResNode = CurDAG->getTargetNode(Alpha::ZAPNOTi, MVT::i64, Tmp3, Tmp4);
02475       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02476       Result = SDOperand(ResNode, 0);
02477     }
02478     return;
02479   }
02480 
02481   // Pattern: (imm:i64)<<P:Predicate_immConst2PartInt>><<X:SExt32>>:$imm
02482   // Emits: (ZAPNOTi:i64 (LDA:i64 (LL16:i64 (SExt32:i64 (imm:i64)<<P:Predicate_immConst2PartInt>><<X:SExt32>>:$imm)), (LDAH:i64 (LH16:i64 (SExt32:i64 (imm:i64)<<P:Predicate_immConst2PartInt>><<X:SExt32>>:$imm)), R31:i64)), 15:i64)
02483   // Pattern complexity = 3  cost = 3
02484   if (Predicate_immConst2PartInt(N.Val)) {
02485     uint64_t Tmp0C = (uint64_t)cast<ConstantSDNode>(N)->getValue();
02486     Tmp0 = CurDAG->getTargetConstant(Tmp0C, MVT::i64);
02487     Tmp1 = Transform_SExt32(Tmp0.Val);
02488     Tmp2 = Transform_LL16(Tmp1.Val);
02489     Tmp3 = Transform_SExt32(Tmp0.Val);
02490     Tmp4 = Transform_LH16(Tmp3.Val);
02491     Tmp5 = CurDAG->getRegister(Alpha::R31, MVT::i64);
02492     Tmp6 = SDOperand(CurDAG->getTargetNode(Alpha::LDAH, MVT::i64, Tmp4, Tmp5), 0);
02493     Tmp7 = SDOperand(CurDAG->getTargetNode(Alpha::LDA, MVT::i64, Tmp2, Tmp6), 0);
02494     Tmp8 = CurDAG->getTargetConstant(15, MVT::i64);
02495     if (N.Val->hasOneUse()) {
02496       Result = CurDAG->SelectNodeTo(N.Val, Alpha::ZAPNOTi, MVT::i64, Tmp7, Tmp8);
02497     } else {
02498       ResNode = CurDAG->getTargetNode(Alpha::ZAPNOTi, MVT::i64, Tmp7, Tmp8);
02499       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02500       Result = SDOperand(ResNode, 0);
02501     }
02502     return;
02503   }
02504   std::cerr << "Cannot yet select: ";
02505   N.Val->dump(CurDAG);
02506   std::cerr << '\n';
02507   abort();
02508 }
02509 
02510 void Select_load(SDOperand &Result, SDOperand N) {
02511   if (N.ResNo == 1 && N.getValue(0).hasOneUse()) {
02512     SDOperand Dummy = CurDAG->getNode(ISD::HANDLENODE, MVT::Other, N);
02513     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, Dummy.Val, 0);
02514     SelectionDAG::InsertISelMapEntry(HandleMap, N.Val, 1, Dummy.Val, 0);
02515     Result = Dummy;
02516     return;
02517   }
02518   SDOperand Chain(0, 0);
02519   SDOperand N1(0, 0);
02520   SDOperand N10(0, 0);
02521   SDOperand N11(0, 0);
02522   SDOperand Tmp0(0, 0);
02523   SDOperand Tmp1(0, 0);
02524   SDNode *ResNode;
02525   Chain = N.getOperand(0);
02526   N1 = N.getOperand(1);
02527   if (N1.getOpcode() == ISD::ADD) {
02528     N10 = N1.getOperand(0);
02529     N11 = N1.getOperand(1);
02530     if (N11.getOpcode() == ISD::Constant &&
02531         Predicate_immSExt16(N11.Val)) {
02532 
02533       // Pattern: (load:i64 (add:i64 GPRC:i64:$RB, (imm:i64)<<P:Predicate_immSExt16>>:$DISP))
02534       // Emits: (LDQ:i64 (imm:i64):$DISP, GPRC:i64:$RB)
02535       // Pattern complexity = 7  cost = 1
02536       if (N.Val->getValueType(0) == MVT::i64) {
02537         uint64_t Tmp0C = (uint64_t)cast<ConstantSDNode>(N11)->getValue();
02538         Tmp0 = CurDAG->getTargetConstant(Tmp0C, MVT::i64);
02539         Select(Tmp1, N10);
02540         Select(Chain, Chain);
02541         ResNode = CurDAG->getTargetNode(Alpha::LDQ, MVT::i64, MVT::Other, Tmp0, Tmp1, Chain);
02542         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
02543         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
02544         if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
02545         Result = SDOperand(ResNode, N.ResNo);
02546         return;
02547       }
02548 
02549       // Pattern: (load:f32 (add:i64 GPRC:i64:$RB, (imm:i64)<<P:Predicate_immSExt16>>:$DISP))
02550       // Emits: (LDS:f32 (imm:i64):$DISP, GPRC:i64:$RB)
02551       // Pattern complexity = 7  cost = 1
02552       if (N.Val->getValueType(0) == MVT::f32) {
02553         uint64_t Tmp0C = (uint64_t)cast<ConstantSDNode>(N11)->getValue();
02554         Tmp0 = CurDAG->getTargetConstant(Tmp0C, MVT::i64);
02555         Select(Tmp1, N10);
02556         Select(Chain, Chain);
02557         ResNode = CurDAG->getTargetNode(Alpha::LDS, MVT::f32, MVT::Other, Tmp0, Tmp1, Chain);
02558         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
02559         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
02560         if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
02561         Result = SDOperand(ResNode, N.ResNo);
02562         return;
02563       }
02564 
02565       // Pattern: (load:f64 (add:i64 GPRC:i64:$RB, (imm:i64)<<P:Predicate_immSExt16>>:$DISP))
02566       // Emits: (LDT:f64 (imm:i64):$DISP, GPRC:i64:$RB)
02567       // Pattern complexity = 7  cost = 1
02568       if (N.Val->getValueType(0) == MVT::f64) {
02569         uint64_t Tmp0C = (uint64_t)cast<ConstantSDNode>(N11)->getValue();
02570         Tmp0 = CurDAG->getTargetConstant(Tmp0C, MVT::i64);
02571         Select(Tmp1, N10);
02572         Select(Chain, Chain);
02573         ResNode = CurDAG->getTargetNode(Alpha::LDT, MVT::f64, MVT::Other, Tmp0, Tmp1, Chain);
02574         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
02575         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
02576         if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
02577         Result = SDOperand(ResNode, N.ResNo);
02578         return;
02579       }
02580     }
02581   }
02582   if (N1.getOpcode() == AlphaISD::GPRelLo) {
02583     N10 = N1.getOperand(0);
02584     if (N10.getOpcode() == ISD::TargetGlobalAddress) {
02585       N11 = N1.getOperand(1);
02586 
02587       // Pattern: (load:i64 (Alpha_gprello:i64 (tglobaladdr:i64):$DISP, GPRC:i64:$RB))
02588       // Emits: (LDQr:i64 (tglobaladdr:i64):$DISP, GPRC:i64:$RB)
02589       // Pattern complexity = 6  cost = 1
02590       if (N.Val->getValueType(0) == MVT::i64) {
02591         Tmp0 = N10;
02592         Select(Tmp1, N11);
02593         Select(Chain, Chain);
02594         ResNode = CurDAG->getTargetNode(Alpha::LDQr, MVT::i64, MVT::Other, Tmp0, Tmp1, Chain);
02595         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
02596         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
02597         if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
02598         Result = SDOperand(ResNode, N.ResNo);
02599         return;
02600       }
02601 
02602       // Pattern: (load:f32 (Alpha_gprello:i64 (tglobaladdr:i64):$DISP, GPRC:i64:$RB))
02603       // Emits: (LDSr:f32 (tglobaladdr:i64):$DISP, GPRC:i64:$RB)
02604       // Pattern complexity = 6  cost = 1
02605       if (N.Val->getValueType(0) == MVT::f32) {
02606         Tmp0 = N10;
02607         Select(Tmp1, N11);
02608         Select(Chain, Chain);
02609         ResNode = CurDAG->getTargetNode(Alpha::LDSr, MVT::f32, MVT::Other, Tmp0, Tmp1, Chain);
02610         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
02611         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
02612         if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
02613         Result = SDOperand(ResNode, N.ResNo);
02614         return;
02615       }
02616 
02617       // Pattern: (load:f64 (Alpha_gprello:i64 (tglobaladdr:i64):$DISP, GPRC:i64:$RB))
02618       // Emits: (LDTr:f64 (tglobaladdr:i64):$DISP, GPRC:i64:$RB)
02619       // Pattern complexity = 6  cost = 1
02620       if (N.Val->getValueType(0) == MVT::f64) {
02621         Tmp0 = N10;
02622         Select(Tmp1, N11);
02623         Select(Chain, Chain);
02624         ResNode = CurDAG->getTargetNode(Alpha::LDTr, MVT::f64, MVT::Other, Tmp0, Tmp1, Chain);
02625         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
02626         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
02627         if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
02628         Result = SDOperand(ResNode, N.ResNo);
02629         return;
02630       }
02631     }
02632     if (N10.getOpcode() == ISD::TargetConstantPool) {
02633       N11 = N1.getOperand(1);
02634 
02635       // Pattern: (load:i64 (Alpha_gprello:i64 (tconstpool:i64):$DISP, GPRC:i64:$RB))
02636       // Emits: (LDQr:i64 (tconstpool:i64):$DISP, GPRC:i64:$RB)
02637       // Pattern complexity = 6  cost = 1
02638       if (N.Val->getValueType(0) == MVT::i64) {
02639         Tmp0 = N10;
02640         Select(Tmp1, N11);
02641         Select(Chain, Chain);
02642         ResNode = CurDAG->getTargetNode(Alpha::LDQr, MVT::i64, MVT::Other, Tmp0, Tmp1, Chain);
02643         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
02644         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
02645         if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
02646         Result = SDOperand(ResNode, N.ResNo);
02647         return;
02648       }
02649 
02650       // Pattern: (load:f32 (Alpha_gprello:i64 (tconstpool:i64):$DISP, GPRC:i64:$RB))
02651       // Emits: (LDSr:f32 (tconstpool:i64):$DISP, GPRC:i64:$RB)
02652       // Pattern complexity = 6  cost = 1
02653       if (N.Val->getValueType(0) == MVT::f32) {
02654         Tmp0 = N10;
02655         Select(Tmp1, N11);
02656         Select(Chain, Chain);
02657         ResNode = CurDAG->getTargetNode(Alpha::LDSr, MVT::f32, MVT::Other, Tmp0, Tmp1, Chain);
02658         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
02659         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
02660         if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
02661         Result = SDOperand(ResNode, N.ResNo);
02662         return;
02663       }
02664 
02665       // Pattern: (load:f64 (Alpha_gprello:i64 (tconstpool:i64):$DISP, GPRC:i64:$RB))
02666       // Emits: (LDTr:f64 (tconstpool:i64):$DISP, GPRC:i64:$RB)
02667       // Pattern complexity = 6  cost = 1
02668       if (N.Val->getValueType(0) == MVT::f64) {
02669         Tmp0 = N10;
02670         Select(Tmp1, N11);
02671         Select(Chain, Chain);
02672         ResNode = CurDAG->getTargetNode(Alpha::LDTr, MVT::f64, MVT::Other, Tmp0, Tmp1, Chain);
02673         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
02674         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
02675         if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
02676         Result = SDOperand(ResNode, N.ResNo);
02677         return;
02678       }
02679     }
02680   }
02681 
02682   // Pattern: (load:i64 GPRC:i64:$addr)
02683   // Emits: (LDQ:i64 0:i64, GPRC:i64:$addr)
02684   // Pattern complexity = 2  cost = 1
02685   if (N.Val->getValueType(0) == MVT::i64) {
02686     Tmp0 = CurDAG->getTargetConstant(0, MVT::i64);
02687     Select(Tmp1, N1);
02688     Select(Chain, Chain);
02689     ResNode = CurDAG->getTargetNode(Alpha::LDQ, MVT::i64, MVT::Other, Tmp0, Tmp1, Chain);
02690     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
02691     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
02692     if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
02693     Result = SDOperand(ResNode, N.ResNo);
02694     return;
02695   }
02696 
02697   // Pattern: (load:f64 GPRC:i64:$addr)
02698   // Emits: (LDT:f64 0:i64, GPRC:i64:$addr)
02699   // Pattern complexity = 2  cost = 1
02700   if (N.Val->getValueType(0) == MVT::f64) {
02701     Tmp0 = CurDAG->getTargetConstant(0, MVT::i64);
02702     Select(Tmp1, N1);
02703     Select(Chain, Chain);
02704     ResNode = CurDAG->getTargetNode(Alpha::LDT, MVT::f64, MVT::Other, Tmp0, Tmp1, Chain);
02705     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
02706     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
02707     if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
02708     Result = SDOperand(ResNode, N.ResNo);
02709     return;
02710   }
02711 
02712   // Pattern: (load:f32 GPRC:i64:$addr)
02713   // Emits: (LDS:f32 0:i64, GPRC:i64:$addr)
02714   // Pattern complexity = 2  cost = 1
02715   if (N.Val->getValueType(0) == MVT::f32) {
02716     Tmp0 = CurDAG->getTargetConstant(0, MVT::i64);
02717     Select(Tmp1, N1);
02718     Select(Chain, Chain);
02719     ResNode = CurDAG->getTargetNode(Alpha::LDS, MVT::f32, MVT::Other, Tmp0, Tmp1, Chain);
02720     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
02721     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
02722     if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
02723     Result = SDOperand(ResNode, N.ResNo);
02724     return;
02725   }
02726   std::cerr << "Cannot yet select: ";
02727   N.Val->dump(CurDAG);
02728   std::cerr << '\n';
02729   abort();
02730 }
02731 
02732 void Select_mul(SDOperand &Result, SDOperand N) {
02733   SDOperand N0(0, 0);
02734   SDOperand N1(0, 0);
02735   SDOperand Tmp0(0, 0);
02736   SDOperand Tmp1(0, 0);
02737   SDOperand Tmp2(0, 0);
02738   SDOperand Tmp3(0, 0);
02739   SDOperand Tmp4(0, 0);
02740   SDOperand Tmp5(0, 0);
02741   SDNode *ResNode;
02742   N0 = N.getOperand(0);
02743   {
02744     N1 = N.getOperand(1);
02745 
02746     // Pattern: (mul:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immUExt8ME>>:$L)
02747     // Emits: (MULQi:i64 GPRC:i64:$RA, (imm:i64):$L)
02748     // Pattern complexity = 5  cost = 1
02749     if (N1.getOpcode() == ISD::Constant &&
02750         Predicate_immUExt8ME(N1.Val)) {
02751       Select(Tmp0, N0);
02752       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
02753       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
02754       if (N.Val->hasOneUse()) {
02755         Result = CurDAG->SelectNodeTo(N.Val, Alpha::MULQi, MVT::i64, Tmp0, Tmp1);
02756       } else {
02757         ResNode = CurDAG->getTargetNode(Alpha::MULQi, MVT::i64, Tmp0, Tmp1);
02758         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02759         Result = SDOperand(ResNode, 0);
02760       }
02761       return;
02762     }
02763     if (isa<ConstantSDNode>(N1)) {
02764       int64_t CN0 = cast<ConstantSDNode>(N1)->getSignExtended();
02765 
02766       // Pattern: (mul:i64 GPRC:i64:$RA, 5:i64)
02767       // Emits: (S4ADDQ:i64 GPRC:i64:$RA, GPRC:i64:$RA)
02768       // Pattern complexity = 5  cost = 1
02769       if (CN0 == 5) {
02770         Select(Tmp1, N0);
02771         if (N.Val->hasOneUse()) {
02772           Result = CurDAG->SelectNodeTo(N.Val, Alpha::S4ADDQ, MVT::i64, Tmp1, Tmp1);
02773         } else {
02774           ResNode = CurDAG->getTargetNode(Alpha::S4ADDQ, MVT::i64, Tmp1, Tmp1);
02775           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02776           Result = SDOperand(ResNode, 0);
02777         }
02778         return;
02779       }
02780 
02781       // Pattern: (mul:i64 GPRC:i64:$RA, 3:i64)
02782       // Emits: (S4SUBQ:i64 GPRC:i64:$RA, GPRC:i64:$RA)
02783       // Pattern complexity = 5  cost = 1
02784       if (CN0 == 3) {
02785         Select(Tmp1, N0);
02786         if (N.Val->hasOneUse()) {
02787           Result = CurDAG->SelectNodeTo(N.Val, Alpha::S4SUBQ, MVT::i64, Tmp1, Tmp1);
02788         } else {
02789           ResNode = CurDAG->getTargetNode(Alpha::S4SUBQ, MVT::i64, Tmp1, Tmp1);
02790           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02791           Result = SDOperand(ResNode, 0);
02792         }
02793         return;
02794       }
02795     }
02796   }
02797   if (isa<ConstantSDNode>(N0)) {
02798     int64_t CN0 = cast<ConstantSDNode>(N0)->getSignExtended();
02799 
02800     // Pattern: (mul:i64 5:i64, GPRC:i64:$RA)
02801     // Emits: (S4ADDQ:i64 GPRC:i64:$RA, GPRC:i64:$RA)
02802     // Pattern complexity = 5  cost = 1
02803     if (CN0 == 5) {
02804       N1 = N.getOperand(1);
02805       Select(Tmp1, N1);
02806       if (N.Val->hasOneUse()) {
02807         Result = CurDAG->SelectNodeTo(N.Val, Alpha::S4ADDQ, MVT::i64, Tmp1, Tmp1);
02808       } else {
02809         ResNode = CurDAG->getTargetNode(Alpha::S4ADDQ, MVT::i64, Tmp1, Tmp1);
02810         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02811         Result = SDOperand(ResNode, 0);
02812       }
02813       return;
02814     }
02815 
02816     // Pattern: (mul:i64 3:i64, GPRC:i64:$RA)
02817     // Emits: (S4SUBQ:i64 GPRC:i64:$RA, GPRC:i64:$RA)
02818     // Pattern complexity = 5  cost = 1
02819     if (CN0 == 3) {
02820       N1 = N.getOperand(1);
02821       Select(Tmp1, N1);
02822       if (N.Val->hasOneUse()) {
02823         Result = CurDAG->SelectNodeTo(N.Val, Alpha::S4SUBQ, MVT::i64, Tmp1, Tmp1);
02824       } else {
02825         ResNode = CurDAG->getTargetNode(Alpha::S4SUBQ, MVT::i64, Tmp1, Tmp1);
02826         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02827         Result = SDOperand(ResNode, 0);
02828       }
02829       return;
02830     }
02831   }
02832   N1 = N.getOperand(1);
02833   if (N1.getOpcode() == ISD::Constant) {
02834 
02835     // Pattern: (mul:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immRem1>>:$imm)
02836     // Emits: (ADDQ:i64 (SL:i64 GPRC:i64:$RA, (nearP2X:i64 (imm:i64)<<P:Predicate_immRem1>>:$imm)), GPRC:i64:$RA)
02837     // Pattern complexity = 5  cost = 2
02838     if (Predicate_immRem1(N1.Val)) {
02839       Select(Tmp0, N0);
02840       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
02841       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
02842       Tmp2 = Transform_nearP2X(Tmp1.Val);
02843       Tmp3 = SDOperand(CurDAG->getTargetNode(Alpha::SL, MVT::i64, Tmp0, Tmp2), 0);
02844       if (N.Val->hasOneUse()) {
02845         Result = CurDAG->SelectNodeTo(N.Val, Alpha::ADDQ, MVT::i64, Tmp3, Tmp0);
02846       } else {
02847         ResNode = CurDAG->getTargetNode(Alpha::ADDQ, MVT::i64, Tmp3, Tmp0);
02848         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02849         Result = SDOperand(ResNode, 0);
02850       }
02851       return;
02852     }
02853 
02854     // Pattern: (mul:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immRem4>>:$imm)
02855     // Emits: (S4ADDQ:i64 GPRC:i64:$RA, (SL:i64 GPRC:i64:$RA, (nearP2X:i64 (imm:i64)<<P:Predicate_immRem4>>:$imm)))
02856     // Pattern complexity = 5  cost = 2
02857     if (Predicate_immRem4(N1.Val)) {
02858       Select(Tmp0, N0);
02859       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
02860       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
02861       Tmp2 = Transform_nearP2X(Tmp1.Val);
02862       Tmp3 = SDOperand(CurDAG->getTargetNode(Alpha::SL, MVT::i64, Tmp0, Tmp2), 0);
02863       if (N.Val->hasOneUse()) {
02864         Result = CurDAG->SelectNodeTo(N.Val, Alpha::S4ADDQ, MVT::i64, Tmp0, Tmp3);
02865       } else {
02866         ResNode = CurDAG->getTargetNode(Alpha::S4ADDQ, MVT::i64, Tmp0, Tmp3);
02867         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02868         Result = SDOperand(ResNode, 0);
02869       }
02870       return;
02871     }
02872 
02873     // Pattern: (mul:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immRem1n>>:$imm)
02874     // Emits: (SUBQ:i64 (SL:i64 GPRC:i64:$RA, (nearP2X:i64 (imm:i64)<<P:Predicate_immRem1n>>:$imm)), GPRC:i64:$RA)
02875     // Pattern complexity = 5  cost = 2
02876     if (Predicate_immRem1n(N1.Val)) {
02877       Select(Tmp0, N0);
02878       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
02879       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
02880       Tmp2 = Transform_nearP2X(Tmp1.Val);
02881       Tmp3 = SDOperand(CurDAG->getTargetNode(Alpha::SL, MVT::i64, Tmp0, Tmp2), 0);
02882       if (N.Val->hasOneUse()) {
02883         Result = CurDAG->SelectNodeTo(N.Val, Alpha::SUBQ, MVT::i64, Tmp3, Tmp0);
02884       } else {
02885         ResNode = CurDAG->getTargetNode(Alpha::SUBQ, MVT::i64, Tmp3, Tmp0);
02886         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02887         Result = SDOperand(ResNode, 0);
02888       }
02889       return;
02890     }
02891 
02892     // Pattern: (mul:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immRem3>>:$imm)
02893     // Emits: (ADDQ:i64 (SL:i64 GPRC:i64:$RA, (nearP2X:i64 (imm:i64)<<P:Predicate_immRem3>>:$imm)), (S4SUBQ:i64 GPRC:i64:$RA, GPRC:i64:$RA))
02894     // Pattern complexity = 5  cost = 3
02895     if (Predicate_immRem3(N1.Val)) {
02896       Select(Tmp0, N0);
02897       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
02898       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
02899       Tmp2 = Transform_nearP2X(Tmp1.Val);
02900       Tmp3 = SDOperand(CurDAG->getTargetNode(Alpha::SL, MVT::i64, Tmp0, Tmp2), 0);
02901       Tmp4 = SDOperand(CurDAG->getTargetNode(Alpha::S4SUBQ, MVT::i64, Tmp0, Tmp0), 0);
02902       if (N.Val->hasOneUse()) {
02903         Result = CurDAG->SelectNodeTo(N.Val, Alpha::ADDQ, MVT::i64, Tmp3, Tmp4);
02904       } else {
02905         ResNode = CurDAG->getTargetNode(Alpha::ADDQ, MVT::i64, Tmp3, Tmp4);
02906         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02907         Result = SDOperand(ResNode, 0);
02908       }
02909       return;
02910     }
02911 
02912     // Pattern: (mul:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immRem5>>:$imm)
02913     // Emits: (ADDQ:i64 (SL:i64 GPRC:i64:$RA, (nearP2X:i64 (imm:i64)<<P:Predicate_immRem5>>:$imm)), (S4ADDQ:i64 GPRC:i64:$RA, GPRC:i64:$RA))
02914     // Pattern complexity = 5  cost = 3
02915     if (Predicate_immRem5(N1.Val)) {
02916       Select(Tmp0, N0);
02917       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
02918       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
02919       Tmp2 = Transform_nearP2X(Tmp1.Val);
02920       Tmp3 = SDOperand(CurDAG->getTargetNode(Alpha::SL, MVT::i64, Tmp0, Tmp2), 0);
02921       Tmp4 = SDOperand(CurDAG->getTargetNode(Alpha::S4ADDQ, MVT::i64, Tmp0, Tmp0), 0);
02922       if (N.Val->hasOneUse()) {
02923         Result = CurDAG->SelectNodeTo(N.Val, Alpha::ADDQ, MVT::i64, Tmp3, Tmp4);
02924       } else {
02925         ResNode = CurDAG->getTargetNode(Alpha::ADDQ, MVT::i64, Tmp3, Tmp4);
02926         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02927         Result = SDOperand(ResNode, 0);
02928       }
02929       return;
02930     }
02931 
02932     // Pattern: (mul:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immRemP2>>:$imm)
02933     // Emits: (ADDQ:i64 (SL:i64 GPRC:i64:$RA, (nearP2X:i64 (imm:i64)<<P:Predicate_immRemP2>>:$imm)), (SLi:i64 GPRC:i64:$RA, (nearP2RemX:i64 (imm:i64)<<P:Predicate_immRemP2>>:$imm)))
02934     // Pattern complexity = 5  cost = 3
02935     if (Predicate_immRemP2(N1.Val)) {
02936       Select(Tmp0, N0);
02937       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
02938       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
02939       Tmp2 = Transform_nearP2X(Tmp1.Val);
02940       Tmp3 = SDOperand(CurDAG->getTargetNode(Alpha::SL, MVT::i64, Tmp0, Tmp2), 0);
02941       Tmp4 = Transform_nearP2RemX(Tmp1.Val);
02942       Tmp5 = SDOperand(CurDAG->getTargetNode(Alpha::SLi, MVT::i64, Tmp0, Tmp4), 0);
02943       if (N.Val->hasOneUse()) {
02944         Result = CurDAG->SelectNodeTo(N.Val, Alpha::ADDQ, MVT::i64, Tmp3, Tmp5);
02945       } else {
02946         ResNode = CurDAG->getTargetNode(Alpha::ADDQ, MVT::i64, Tmp3, Tmp5);
02947         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02948         Result = SDOperand(ResNode, 0);
02949       }
02950       return;
02951     }
02952 
02953     // Pattern: (mul:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immRem3n>>:$imm)
02954     // Emits: (SUBQ:i64 (SL:i64 GPRC:i64:$RA, (nearP2X:i64 (imm:i64)<<P:Predicate_immRem3n>>:$imm)), (S4SUBQ:i64 GPRC:i64:$RA, GPRC:i64:$RA))
02955     // Pattern complexity = 5  cost = 3
02956     if (Predicate_immRem3n(N1.Val)) {
02957       Select(Tmp0, N0);
02958       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
02959       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
02960       Tmp2 = Transform_nearP2X(Tmp1.Val);
02961       Tmp3 = SDOperand(CurDAG->getTargetNode(Alpha::SL, MVT::i64, Tmp0, Tmp2), 0);
02962       Tmp4 = SDOperand(CurDAG->getTargetNode(Alpha::S4SUBQ, MVT::i64, Tmp0, Tmp0), 0);
02963       if (N.Val->hasOneUse()) {
02964         Result = CurDAG->SelectNodeTo(N.Val, Alpha::SUBQ, MVT::i64, Tmp3, Tmp4);
02965       } else {
02966         ResNode = CurDAG->getTargetNode(Alpha::SUBQ, MVT::i64, Tmp3, Tmp4);
02967         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02968         Result = SDOperand(ResNode, 0);
02969       }
02970       return;
02971     }
02972 
02973     // Pattern: (mul:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immRem5n>>:$imm)
02974     // Emits: (SUBQ:i64 (SL:i64 GPRC:i64:$RA, (nearP2X:i64 (imm:i64)<<P:Predicate_immRem5n>>:$imm)), (S4ADDQ:i64 GPRC:i64:$RA, GPRC:i64:$RA))
02975     // Pattern complexity = 5  cost = 3
02976     if (Predicate_immRem5n(N1.Val)) {
02977       Select(Tmp0, N0);
02978       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
02979       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
02980       Tmp2 = Transform_nearP2X(Tmp1.Val);
02981       Tmp3 = SDOperand(CurDAG->getTargetNode(Alpha::SL, MVT::i64, Tmp0, Tmp2), 0);
02982       Tmp4 = SDOperand(CurDAG->getTargetNode(Alpha::S4ADDQ, MVT::i64, Tmp0, Tmp0), 0);
02983       if (N.Val->hasOneUse()) {
02984         Result = CurDAG->SelectNodeTo(N.Val, Alpha::SUBQ, MVT::i64, Tmp3, Tmp4);
02985       } else {
02986         ResNode = CurDAG->getTargetNode(Alpha::SUBQ, MVT::i64, Tmp3, Tmp4);
02987         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
02988         Result = SDOperand(ResNode, 0);
02989       }
02990       return;
02991     }
02992 
02993     // Pattern: (mul:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immRemP2n>>:$imm)
02994     // Emits: (SUBQ:i64 (SL:i64 GPRC:i64:$RA, (nearP2X:i64 (imm:i64)<<P:Predicate_immRemP2n>>:$imm)), (SLi:i64 GPRC:i64:$RA, (nearP2RemX:i64 (imm:i64)<<P:Predicate_immRemP2n>>:$imm)))
02995     // Pattern complexity = 5  cost = 3
02996     if (Predicate_immRemP2n(N1.Val)) {
02997       Select(Tmp0, N0);
02998       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
02999       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
03000       Tmp2 = Transform_nearP2X(Tmp1.Val);
03001       Tmp3 = SDOperand(CurDAG->getTargetNode(Alpha::SL, MVT::i64, Tmp0, Tmp2), 0);
03002       Tmp4 = Transform_nearP2RemX(Tmp1.Val);
03003       Tmp5 = SDOperand(CurDAG->getTargetNode(Alpha::SLi, MVT::i64, Tmp0, Tmp4), 0);
03004       if (N.Val->hasOneUse()) {
03005         Result = CurDAG->SelectNodeTo(N.Val, Alpha::SUBQ, MVT::i64, Tmp3, Tmp5);
03006       } else {
03007         ResNode = CurDAG->getTargetNode(Alpha::SUBQ, MVT::i64, Tmp3, Tmp5);
03008         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03009         Result = SDOperand(ResNode, 0);
03010       }
03011       return;
03012     }
03013   }
03014 
03015   // Pattern: (mul:i64 GPRC:i64:$RA, GPRC:i64:$RB)
03016   // Emits: (MULQ:i64 GPRC:i64:$RA, GPRC:i64:$RB)
03017   // Pattern complexity = 2  cost = 1
03018   Select(Tmp0, N0);
03019   Select(Tmp1, N1);
03020   if (N.Val->hasOneUse()) {
03021     Result = CurDAG->SelectNodeTo(N.Val, Alpha::MULQ, MVT::i64, Tmp0, Tmp1);
03022   } else {
03023     ResNode = CurDAG->getTargetNode(Alpha::MULQ, MVT::i64, Tmp0, Tmp1);
03024     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03025     Result = SDOperand(ResNode, 0);
03026   }
03027   return;
03028 }
03029 
03030 void Select_mulhs(SDOperand &Result, SDOperand N) {
03031   SDOperand N0(0, 0);
03032   SDOperand N1(0, 0);
03033   SDOperand Tmp0(0, 0);
03034   SDOperand Tmp1(0, 0);
03035   SDOperand Tmp2(0, 0);
03036   SDOperand Tmp3(0, 0);
03037   SDOperand Tmp4(0, 0);
03038   SDOperand Tmp5(0, 0);
03039   SDOperand Tmp6(0, 0);
03040   SDOperand Tmp7(0, 0);
03041   SDNode *ResNode;
03042   N0 = N.getOperand(0);
03043   N1 = N.getOperand(1);
03044   Select(Tmp0, N0);
03045   Select(Tmp1, N1);
03046   Tmp2 = SDOperand(CurDAG->getTargetNode(Alpha::UMULH, MVT::i64, Tmp0, Tmp1), 0);
03047   Tmp3 = CurDAG->getRegister(Alpha::R31, MVT::i64);
03048   Tmp4 = SDOperand(CurDAG->getTargetNode(Alpha::CMOVGE, MVT::i64, Tmp1, Tmp3, Tmp0), 0);
03049   Tmp5 = CurDAG->getRegister(Alpha::R31, MVT::i64);
03050   Tmp6 = SDOperand(CurDAG->getTargetNode(Alpha::CMOVGE, MVT::i64, Tmp0, Tmp5, Tmp1), 0);
03051   Tmp7 = SDOperand(CurDAG->getTargetNode(Alpha::ADDQ, MVT::i64, Tmp4, Tmp6), 0);
03052   if (N.Val->hasOneUse()) {
03053     Result = CurDAG->SelectNodeTo(N.Val, Alpha::SUBQ, MVT::i64, Tmp2, Tmp7);
03054   } else {
03055     ResNode = CurDAG->getTargetNode(Alpha::SUBQ, MVT::i64, Tmp2, Tmp7);
03056     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03057     Result = SDOperand(ResNode, 0);
03058   }
03059   return;
03060 }
03061 
03062 void Select_mulhu(SDOperand &Result, SDOperand N) {
03063   SDOperand N0(0, 0);
03064   SDOperand N1(0, 0);
03065   SDOperand Tmp0(0, 0);
03066   SDOperand Tmp1(0, 0);
03067   SDNode *ResNode;
03068   N0 = N.getOperand(0);
03069   N1 = N.getOperand(1);
03070 
03071   // Pattern: (mulhu:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immUExt8>>:$L)
03072   // Emits: (UMULHi:i64 GPRC:i64:$RA, (imm:i64):$L)
03073   // Pattern complexity = 5  cost = 1
03074   if (N1.getOpcode() == ISD::Constant &&
03075       Predicate_immUExt8(N1.Val)) {
03076     Select(Tmp0, N0);
03077     uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
03078     Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
03079     if (N.Val->hasOneUse()) {
03080       Result = CurDAG->SelectNodeTo(N.Val, Alpha::UMULHi, MVT::i64, Tmp0, Tmp1);
03081     } else {
03082       ResNode = CurDAG->getTargetNode(Alpha::UMULHi, MVT::i64, Tmp0, Tmp1);
03083       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03084       Result = SDOperand(ResNode, 0);
03085     }
03086     return;
03087   }
03088 
03089   // Pattern: (mulhu:i64 GPRC:i64:$RA, GPRC:i64:$RB)
03090   // Emits: (UMULH:i64 GPRC:i64:$RA, GPRC:i64:$RB)
03091   // Pattern complexity = 2  cost = 1
03092   Select(Tmp0, N0);
03093   Select(Tmp1, N1);
03094   if (N.Val->hasOneUse()) {
03095     Result = CurDAG->SelectNodeTo(N.Val, Alpha::UMULH, MVT::i64, Tmp0, Tmp1);
03096   } else {
03097     ResNode = CurDAG->getTargetNode(Alpha::UMULH, MVT::i64, Tmp0, Tmp1);
03098     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03099     Result = SDOperand(ResNode, 0);
03100   }
03101   return;
03102 }
03103 
03104 void Select_or(SDOperand &Result, SDOperand N) {
03105   SDOperand N0(0, 0);
03106   SDOperand N00(0, 0);
03107   SDOperand N01(0, 0);
03108   SDOperand N1(0, 0);
03109   SDOperand N10(0, 0);
03110   SDOperand N11(0, 0);
03111   SDOperand Tmp0(0, 0);
03112   SDOperand Tmp1(0, 0);
03113   SDOperand Tmp2(0, 0);
03114   SDNode *ResNode;
03115   N0 = N.getOperand(0);
03116 
03117   // Pattern: (or:i64 GPRC:i64:$RA, (xor:i64 GPRC:i64:$RB, (imm:i64)<<P:Predicate_immAllOnes>>))
03118   // Emits: (ORNOT:i64 GPRC:i64:$RA, GPRC:i64:$RB)
03119   // Pattern complexity = 7  cost = 1
03120   {
03121     N1 = N.getOperand(1);
03122     if (N1.getOpcode() == ISD::XOR) {
03123       N10 = N1.getOperand(0);
03124       N11 = N1.getOperand(1);
03125       if (N11.getOpcode() == ISD::Constant &&
03126           Predicate_immAllOnes(N11.Val)) {
03127         Select(Tmp0, N0);
03128         Select(Tmp1, N10);
03129         if (N.Val->hasOneUse()) {
03130           Result = CurDAG->SelectNodeTo(N.Val, Alpha::ORNOT, MVT::i64, Tmp0, Tmp1);
03131         } else {
03132           ResNode = CurDAG->getTargetNode(Alpha::ORNOT, MVT::i64, Tmp0, Tmp1);
03133           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03134           Result = SDOperand(ResNode, 0);
03135         }
03136         return;
03137       }
03138     }
03139   }
03140 
03141   // Pattern: (or:i64 (xor:i64 GPRC:i64:$RB, (imm:i64)<<P:Predicate_immAllOnes>>), GPRC:i64:$RA)
03142   // Emits: (ORNOT:i64 GPRC:i64:$RA, GPRC:i64:$RB)
03143   // Pattern complexity = 7  cost = 1
03144   if (N0.getOpcode() == ISD::XOR) {
03145     N00 = N0.getOperand(0);
03146     N01 = N0.getOperand(1);
03147     if (N01.getOpcode() == ISD::Constant &&
03148         Predicate_immAllOnes(N01.Val)) {
03149       N1 = N.getOperand(1);
03150       Select(Tmp0, N1);
03151       Select(Tmp1, N00);
03152       if (N.Val->hasOneUse()) {
03153         Result = CurDAG->SelectNodeTo(N.Val, Alpha::ORNOT, MVT::i64, Tmp0, Tmp1);
03154       } else {
03155         ResNode = CurDAG->getTargetNode(Alpha::ORNOT, MVT::i64, Tmp0, Tmp1);
03156         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03157         Result = SDOperand(ResNode, 0);
03158       }
03159       return;
03160     }
03161   }
03162   N1 = N.getOperand(1);
03163   if (N1.getOpcode() == ISD::Constant) {
03164 
03165     // Pattern: (or:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immUExt8>>:$L)
03166     // Emits: (BISi:i64 GPRC:i64:$RA, (imm:i64):$L)
03167     // Pattern complexity = 5  cost = 1
03168     if (Predicate_immUExt8(N1.Val)) {
03169       Select(Tmp0, N0);
03170       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
03171       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
03172       if (N.Val->hasOneUse()) {
03173         Result = CurDAG->SelectNodeTo(N.Val, Alpha::BISi, MVT::i64, Tmp0, Tmp1);
03174       } else {
03175         ResNode = CurDAG->getTargetNode(Alpha::BISi, MVT::i64, Tmp0, Tmp1);
03176         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03177         Result = SDOperand(ResNode, 0);
03178       }
03179       return;
03180     }
03181 
03182     // Pattern: (or:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immUExt8inv>><<X:invX>>:$L)
03183     // Emits: (ORNOTi:i64 GPRC:i64:$RA, (invX:i64 (imm:i64):$L))
03184     // Pattern complexity = 5  cost = 1
03185     if (Predicate_immUExt8inv(N1.Val)) {
03186       Select(Tmp0, N0);
03187       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
03188       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
03189       Tmp2 = Transform_invX(Tmp1.Val);
03190       if (N.Val->hasOneUse()) {
03191         Result = CurDAG->SelectNodeTo(N.Val, Alpha::ORNOTi, MVT::i64, Tmp0, Tmp2);
03192       } else {
03193         ResNode = CurDAG->getTargetNode(Alpha::ORNOTi, MVT::i64, Tmp0, Tmp2);
03194         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03195         Result = SDOperand(ResNode, 0);
03196       }
03197       return;
03198     }
03199   }
03200 
03201   // Pattern: (or:i64 GPRC:i64:$RA, GPRC:i64:$RB)
03202   // Emits: (BIS:i64 GPRC:i64:$RA, GPRC:i64:$RB)
03203   // Pattern complexity = 2  cost = 1
03204   Select(Tmp0, N0);
03205   Select(Tmp1, N1);
03206   if (N.Val->hasOneUse()) {
03207     Result = CurDAG->SelectNodeTo(N.Val, Alpha::BIS, MVT::i64, Tmp0, Tmp1);
03208   } else {
03209     ResNode = CurDAG->getTargetNode(Alpha::BIS, MVT::i64, Tmp0, Tmp1);
03210     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03211     Result = SDOperand(ResNode, 0);
03212   }
03213   return;
03214 }
03215 
03216 void Select_select(SDOperand &Result, SDOperand N) {
03217   SDOperand N0(0, 0);
03218   SDOperand N00(0, 0);
03219   SDOperand N01(0, 0);
03220   SDOperand N02(0, 0);
03221   SDOperand N1(0, 0);
03222   SDOperand N2(0, 0);
03223   SDOperand Tmp0(0, 0);
03224   SDOperand Tmp1(0, 0);
03225   SDOperand Tmp2(0, 0);
03226   SDOperand Tmp3(0, 0);
03227   SDOperand Tmp4(0, 0);
03228   SDNode *ResNode;
03229   N0 = N.getOperand(0);
03230   if (N0.getOpcode() == ISD::SETCC) {
03231     N00 = N0.getOperand(0);
03232     N01 = N0.getOperand(1);
03233     if (isa<ConstantSDNode>(N01)) {
03234       int64_t CN0 = cast<ConstantSDNode>(N01)->getSignExtended();
03235       if (CN0 == 0) {
03236         N02 = N0.getOperand(2);
03237 
03238         // Pattern: (select:i64 (setcc:i64 GPRC:i64:$RCOND, 0:i64, SETNE:Other), GPRC:i64:$RFALSE, (imm:i64)<<P:Predicate_immUExt8>>:$RTRUE)
03239         // Emits: (CMOVEQi:i64 GPRC:i64:$RFALSE, (imm:i64):$RTRUE, GPRC:i64:$RCOND)
03240         // Pattern complexity = 10  cost = 1
03241         if (cast<CondCodeSDNode>(N02)->get() == ISD::SETNE) {
03242           N1 = N.getOperand(1);
03243           N2 = N.getOperand(2);
03244           if (N2.getOpcode() == ISD::Constant &&
03245               Predicate_immUExt8(N2.Val) &&
03246               N00.Val->getValueType(0) == MVT::i64) {
03247             Select(Tmp1, N1);
03248             uint64_t Tmp2C = (uint64_t)cast<ConstantSDNode>(N2)->getValue();
03249             Tmp2 = CurDAG->getTargetConstant(Tmp2C, MVT::i64);
03250             Select(Tmp3, N00);
03251             if (N.Val->hasOneUse()) {
03252               Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMOVEQi, MVT::i64, Tmp1, Tmp2, Tmp3);
03253             } else {
03254               ResNode = CurDAG->getTargetNode(Alpha::CMOVEQi, MVT::i64, Tmp1, Tmp2, Tmp3);
03255               SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03256               Result = SDOperand(ResNode, 0);
03257             }
03258             return;
03259           }
03260         }
03261 
03262         // Pattern: (select:i64 (setcc:i64 GPRC:i64:$RCOND, 0:i64, SETLT:Other), GPRC:i64:$RFALSE, (imm:i64)<<P:Predicate_immUExt8>>:$RTRUE)
03263         // Emits: (CMOVGEi:i64 GPRC:i64:$RFALSE, (imm:i64):$RTRUE, GPRC:i64:$RCOND)
03264         // Pattern complexity = 10  cost = 1
03265         if (cast<CondCodeSDNode>(N02)->get() == ISD::SETLT) {
03266           N1 = N.getOperand(1);
03267           N2 = N.getOperand(2);
03268           if (N2.getOpcode() == ISD::Constant &&
03269               Predicate_immUExt8(N2.Val) &&
03270               N00.Val->getValueType(0) == MVT::i64) {
03271             Select(Tmp1, N1);
03272             uint64_t Tmp2C = (uint64_t)cast<ConstantSDNode>(N2)->getValue();
03273             Tmp2 = CurDAG->getTargetConstant(Tmp2C, MVT::i64);
03274             Select(Tmp3, N00);
03275             if (N.Val->hasOneUse()) {
03276               Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMOVGEi, MVT::i64, Tmp1, Tmp2, Tmp3);
03277             } else {
03278               ResNode = CurDAG->getTargetNode(Alpha::CMOVGEi, MVT::i64, Tmp1, Tmp2, Tmp3);
03279               SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03280               Result = SDOperand(ResNode, 0);
03281             }
03282             return;
03283           }
03284         }
03285 
03286         // Pattern: (select:i64 (setcc:i64 GPRC:i64:$RCOND, 0:i64, SETLE:Other), GPRC:i64:$RFALSE, (imm:i64)<<P:Predicate_immUExt8>>:$RTRUE)
03287         // Emits: (CMOVGTi:i64 GPRC:i64:$RFALSE, (imm:i64):$RTRUE, GPRC:i64:$RCOND)
03288         // Pattern complexity = 10  cost = 1
03289         if (cast<CondCodeSDNode>(N02)->get() == ISD::SETLE) {
03290           N1 = N.getOperand(1);
03291           N2 = N.getOperand(2);
03292           if (N2.getOpcode() == ISD::Constant &&
03293               Predicate_immUExt8(N2.Val) &&
03294               N00.Val->getValueType(0) == MVT::i64) {
03295             Select(Tmp1, N1);
03296             uint64_t Tmp2C = (uint64_t)cast<ConstantSDNode>(N2)->getValue();
03297             Tmp2 = CurDAG->getTargetConstant(Tmp2C, MVT::i64);
03298             Select(Tmp3, N00);
03299             if (N.Val->hasOneUse()) {
03300               Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMOVGTi, MVT::i64, Tmp1, Tmp2, Tmp3);
03301             } else {
03302               ResNode = CurDAG->getTargetNode(Alpha::CMOVGTi, MVT::i64, Tmp1, Tmp2, Tmp3);
03303               SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03304               Result = SDOperand(ResNode, 0);
03305             }
03306             return;
03307           }
03308         }
03309 
03310         // Pattern: (select:i64 (setcc:i64 GPRC:i64:$RCOND, 0:i64, SETGT:Other), GPRC:i64:$RFALSE, (imm:i64)<<P:Predicate_immUExt8>>:$RTRUE)
03311         // Emits: (CMOVLEi:i64 GPRC:i64:$RFALSE, (imm:i64):$RTRUE, GPRC:i64:$RCOND)
03312         // Pattern complexity = 10  cost = 1
03313         if (cast<CondCodeSDNode>(N02)->get() == ISD::SETGT) {
03314           N1 = N.getOperand(1);
03315           N2 = N.getOperand(2);
03316           if (N2.getOpcode() == ISD::Constant &&
03317               Predicate_immUExt8(N2.Val) &&
03318               N00.Val->getValueType(0) == MVT::i64) {
03319             Select(Tmp1, N1);
03320             uint64_t Tmp2C = (uint64_t)cast<ConstantSDNode>(N2)->getValue();
03321             Tmp2 = CurDAG->getTargetConstant(Tmp2C, MVT::i64);
03322             Select(Tmp3, N00);
03323             if (N.Val->hasOneUse()) {
03324               Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMOVLEi, MVT::i64, Tmp1, Tmp2, Tmp3);
03325             } else {
03326               ResNode = CurDAG->getTargetNode(Alpha::CMOVLEi, MVT::i64, Tmp1, Tmp2, Tmp3);
03327               SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03328               Result = SDOperand(ResNode, 0);
03329             }
03330             return;
03331           }
03332         }
03333 
03334         // Pattern: (select:i64 (setcc:i64 GPRC:i64:$RCOND, 0:i64, SETGE:Other), GPRC:i64:$RFALSE, (imm:i64)<<P:Predicate_immUExt8>>:$RTRUE)
03335         // Emits: (CMOVLTi:i64 GPRC:i64:$RFALSE, (imm:i64):$RTRUE, GPRC:i64:$RCOND)
03336         // Pattern complexity = 10  cost = 1
03337         if (cast<CondCodeSDNode>(N02)->get() == ISD::SETGE) {
03338           N1 = N.getOperand(1);
03339           N2 = N.getOperand(2);
03340           if (N2.getOpcode() == ISD::Constant &&
03341               Predicate_immUExt8(N2.Val) &&
03342               N00.Val->getValueType(0) == MVT::i64) {
03343             Select(Tmp1, N1);
03344             uint64_t Tmp2C = (uint64_t)cast<ConstantSDNode>(N2)->getValue();
03345             Tmp2 = CurDAG->getTargetConstant(Tmp2C, MVT::i64);
03346             Select(Tmp3, N00);
03347             if (N.Val->hasOneUse()) {
03348               Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMOVLTi, MVT::i64, Tmp1, Tmp2, Tmp3);
03349             } else {
03350               ResNode = CurDAG->getTargetNode(Alpha::CMOVLTi, MVT::i64, Tmp1, Tmp2, Tmp3);
03351               SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03352               Result = SDOperand(ResNode, 0);
03353             }
03354             return;
03355           }
03356         }
03357 
03358         // Pattern: (select:i64 (setcc:i64 GPRC:i64:$RCOND, 0:i64, SETEQ:Other), GPRC:i64:$RFALSE, (imm:i64)<<P:Predicate_immUExt8>>:$RTRUE)
03359         // Emits: (CMOVNEi:i64 GPRC:i64:$RFALSE, (imm:i64):$RTRUE, GPRC:i64:$RCOND)
03360         // Pattern complexity = 10  cost = 1
03361         if (cast<CondCodeSDNode>(N02)->get() == ISD::SETEQ) {
03362           N1 = N.getOperand(1);
03363           N2 = N.getOperand(2);
03364           if (N2.getOpcode() == ISD::Constant &&
03365               Predicate_immUExt8(N2.Val) &&
03366               N00.Val->getValueType(0) == MVT::i64) {
03367             Select(Tmp1, N1);
03368             uint64_t Tmp2C = (uint64_t)cast<ConstantSDNode>(N2)->getValue();
03369             Tmp2 = CurDAG->getTargetConstant(Tmp2C, MVT::i64);
03370             Select(Tmp3, N00);
03371             if (N.Val->hasOneUse()) {
03372               Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMOVNEi, MVT::i64, Tmp1, Tmp2, Tmp3);
03373             } else {
03374               ResNode = CurDAG->getTargetNode(Alpha::CMOVNEi, MVT::i64, Tmp1, Tmp2, Tmp3);
03375               SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03376               Result = SDOperand(ResNode, 0);
03377             }
03378             return;
03379           }
03380         }
03381       }
03382     }
03383   }
03384 
03385   // Pattern: (select:i64 (and:i64 GPRC:i64:$RCOND, 1:i64), GPRC:i64:$RFALSE, (imm:i64)<<P:Predicate_immUExt8>>:$RTRUE)
03386   // Emits: (CMOVLBCi:i64 GPRC:i64:$RFALSE, (imm:i64):$RTRUE, GPRC:i64:$RCOND)
03387   // Pattern complexity = 10  cost = 1
03388   if (N0.getOpcode() == ISD::AND) {
03389     N00 = N0.getOperand(0);
03390     N01 = N0.getOperand(1);
03391     if (isa<ConstantSDNode>(N01)) {
03392       int64_t CN0 = cast<ConstantSDNode>(N01)->getSignExtended();
03393       if (CN0 == 1) {
03394         N1 = N.getOperand(1);
03395         N2 = N.getOperand(2);
03396         if (N2.getOpcode() == ISD::Constant &&
03397             Predicate_immUExt8(N2.Val)) {
03398           Select(Tmp1, N1);
03399           uint64_t Tmp2C = (uint64_t)cast<ConstantSDNode>(N2)->getValue();
03400           Tmp2 = CurDAG->getTargetConstant(Tmp2C, MVT::i64);
03401           Select(Tmp3, N00);
03402           if (N.Val->hasOneUse()) {
03403             Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMOVLBCi, MVT::i64, Tmp1, Tmp2, Tmp3);
03404           } else {
03405             ResNode = CurDAG->getTargetNode(Alpha::CMOVLBCi, MVT::i64, Tmp1, Tmp2, Tmp3);
03406             SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03407             Result = SDOperand(ResNode, 0);
03408           }
03409           return;
03410         }
03411       }
03412     }
03413   }
03414 
03415   // Pattern: (select:i64 (xor:i64 GPRC:i64:$RCOND, 1:i64), GPRC:i64:$RFALSE, (imm:i64)<<P:Predicate_immUExt8>>:$RTRUE)
03416   // Emits: (CMOVLBSi:i64 GPRC:i64:$RFALSE, (imm:i64):$RTRUE, GPRC:i64:$RCOND)
03417   // Pattern complexity = 10  cost = 1
03418   if (N0.getOpcode() == ISD::XOR) {
03419     N00 = N0.getOperand(0);
03420     N01 = N0.getOperand(1);
03421     if (isa<ConstantSDNode>(N01)) {
03422       int64_t CN0 = cast<ConstantSDNode>(N01)->getSignExtended();
03423       if (CN0 == 1) {
03424         N1 = N.getOperand(1);
03425         N2 = N.getOperand(2);
03426         if (N2.getOpcode() == ISD::Constant &&
03427             Predicate_immUExt8(N2.Val)) {
03428           Select(Tmp1, N1);
03429           uint64_t Tmp2C = (uint64_t)cast<ConstantSDNode>(N2)->getValue();
03430           Tmp2 = CurDAG->getTargetConstant(Tmp2C, MVT::i64);
03431           Select(Tmp3, N00);
03432           if (N.Val->hasOneUse()) {
03433             Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMOVLBSi, MVT::i64, Tmp1, Tmp2, Tmp3);
03434           } else {
03435             ResNode = CurDAG->getTargetNode(Alpha::CMOVLBSi, MVT::i64, Tmp1, Tmp2, Tmp3);
03436             SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03437             Result = SDOperand(ResNode, 0);
03438           }
03439           return;
03440         }
03441       }
03442     }
03443   }
03444 
03445   // Pattern: (select:i64 (and:i64 1:i64, GPRC:i64:$RCOND), GPRC:i64:$RFALSE, (imm:i64)<<P:Predicate_immUExt8>>:$RTRUE)
03446   // Emits: (CMOVLBCi:i64 GPRC:i64:$RFALSE, (imm:i64):$RTRUE, GPRC:i64:$RCOND)
03447   // Pattern complexity = 10  cost = 1
03448   if (N0.getOpcode() == ISD::AND) {
03449     N00 = N0.getOperand(0);
03450     if (isa<ConstantSDNode>(N00)) {
03451       int64_t CN0 = cast<ConstantSDNode>(N00)->getSignExtended();
03452       if (CN0 == 1) {
03453         N01 = N0.getOperand(1);
03454         N1 = N.getOperand(1);
03455         N2 = N.getOperand(2);
03456         if (N2.getOpcode() == ISD::Constant &&
03457             Predicate_immUExt8(N2.Val)) {
03458           Select(Tmp1, N1);
03459           uint64_t Tmp2C = (uint64_t)cast<ConstantSDNode>(N2)->getValue();
03460           Tmp2 = CurDAG->getTargetConstant(Tmp2C, MVT::i64);
03461           Select(Tmp3, N01);
03462           if (N.Val->hasOneUse()) {
03463             Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMOVLBCi, MVT::i64, Tmp1, Tmp2, Tmp3);
03464           } else {
03465             ResNode = CurDAG->getTargetNode(Alpha::CMOVLBCi, MVT::i64, Tmp1, Tmp2, Tmp3);
03466             SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03467             Result = SDOperand(ResNode, 0);
03468           }
03469           return;
03470         }
03471       }
03472     }
03473   }
03474   if (N0.getOpcode() == ISD::XOR) {
03475     N00 = N0.getOperand(0);
03476 
03477     // Pattern: (select:i64 (xor:i64 1:i64, GPRC:i64:$RCOND), GPRC:i64:$RFALSE, (imm:i64)<<P:Predicate_immUExt8>>:$RTRUE)
03478     // Emits: (CMOVLBSi:i64 GPRC:i64:$RFALSE, (imm:i64):$RTRUE, GPRC:i64:$RCOND)
03479     // Pattern complexity = 10  cost = 1
03480     if (isa<ConstantSDNode>(N00)) {
03481       int64_t CN0 = cast<ConstantSDNode>(N00)->getSignExtended();
03482       if (CN0 == 1) {
03483         N01 = N0.getOperand(1);
03484         N1 = N.getOperand(1);
03485         N2 = N.getOperand(2);
03486         if (N2.getOpcode() == ISD::Constant &&
03487             Predicate_immUExt8(N2.Val)) {
03488           Select(Tmp1, N1);
03489           uint64_t Tmp2C = (uint64_t)cast<ConstantSDNode>(N2)->getValue();
03490           Tmp2 = CurDAG->getTargetConstant(Tmp2C, MVT::i64);
03491           Select(Tmp3, N01);
03492           if (N.Val->hasOneUse()) {
03493             Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMOVLBSi, MVT::i64, Tmp1, Tmp2, Tmp3);
03494           } else {
03495             ResNode = CurDAG->getTargetNode(Alpha::CMOVLBSi, MVT::i64, Tmp1, Tmp2, Tmp3);
03496             SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03497             Result = SDOperand(ResNode, 0);
03498           }
03499           return;
03500         }
03501       }
03502     }
03503 
03504     // Pattern: (select:i64 (xor:i64 GPRC:i64:$RCOND, 1:i64), GPRC:i64:$RTRUE, GPRC:i64:$RFALSE)
03505     // Emits: (CMOVLBC:i64 GPRC:i64:$RFALSE, GPRC:i64:$RTRUE, GPRC:i64:$RCOND)
03506     // Pattern complexity = 7  cost = 1
03507     N01 = N0.getOperand(1);
03508     if (isa<ConstantSDNode>(N01)) {
03509       int64_t CN0 = cast<ConstantSDNode>(N01)->getSignExtended();
03510       if (CN0 == 1) {
03511         N1 = N.getOperand(1);
03512         N2 = N.getOperand(2);
03513         if (N.Val->getValueType(0) == MVT::i64) {
03514           Select(Tmp1, N2);
03515           Select(Tmp2, N1);
03516           Select(Tmp3, N00);
03517           if (N.Val->hasOneUse()) {
03518             Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMOVLBC, MVT::i64, Tmp1, Tmp2, Tmp3);
03519           } else {
03520             ResNode = CurDAG->getTargetNode(Alpha::CMOVLBC, MVT::i64, Tmp1, Tmp2, Tmp3);
03521             SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03522             Result = SDOperand(ResNode, 0);
03523           }
03524           return;
03525         }
03526       }
03527     }
03528   }
03529 
03530   // Pattern: (select:i64 (and:i64 GPRC:i64:$RCOND, 1:i64), GPRC:i64:$RTRUE, GPRC:i64:$RFALSE)
03531   // Emits: (CMOVLBS:i64 GPRC:i64:$RFALSE, GPRC:i64:$RTRUE, GPRC:i64:$RCOND)
03532   // Pattern complexity = 7  cost = 1
03533   if (N0.getOpcode() == ISD::AND) {
03534     N00 = N0.getOperand(0);
03535     N01 = N0.getOperand(1);
03536     if (isa<ConstantSDNode>(N01)) {
03537       int64_t CN0 = cast<ConstantSDNode>(N01)->getSignExtended();
03538       if (CN0 == 1) {
03539         N1 = N.getOperand(1);
03540         N2 = N.getOperand(2);
03541         if (N.Val->getValueType(0) == MVT::i64) {
03542           Select(Tmp1, N2);
03543           Select(Tmp2, N1);
03544           Select(Tmp3, N00);
03545           if (N.Val->hasOneUse()) {
03546             Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMOVLBS, MVT::i64, Tmp1, Tmp2, Tmp3);
03547           } else {
03548             ResNode = CurDAG->getTargetNode(Alpha::CMOVLBS, MVT::i64, Tmp1, Tmp2, Tmp3);
03549             SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03550             Result = SDOperand(ResNode, 0);
03551           }
03552           return;
03553         }
03554       }
03555     }
03556   }
03557   if (N0.getOpcode() == ISD::SETCC) {
03558     N00 = N0.getOperand(0);
03559     N01 = N0.getOperand(1);
03560     if (isa<ConstantSDNode>(N01)) {
03561       int64_t CN0 = cast<ConstantSDNode>(N01)->getSignExtended();
03562       if (CN0 == 0) {
03563         N02 = N0.getOperand(2);
03564 
03565         // Pattern: (select:i64 (setcc:i64 GPRC:i64:$RCOND, 0:i64, SETEQ:Other), GPRC:i64:$RTRUE, GPRC:i64:$RFALSE)
03566         // Emits: (CMOVEQ:i64 GPRC:i64:$RFALSE, GPRC:i64:$RTRUE, GPRC:i64:$RCOND)
03567         // Pattern complexity = 7  cost = 1
03568         if (cast<CondCodeSDNode>(N02)->get() == ISD::SETEQ) {
03569           N1 = N.getOperand(1);
03570           N2 = N.getOperand(2);
03571           if (N.Val->getValueType(0) == MVT::i64 &&
03572               N00.Val->getValueType(0) == MVT::i64) {
03573             Select(Tmp1, N2);
03574             Select(Tmp2, N1);
03575             Select(Tmp3, N00);
03576             if (N.Val->hasOneUse()) {
03577               Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMOVEQ, MVT::i64, Tmp1, Tmp2, Tmp3);
03578             } else {
03579               ResNode = CurDAG->getTargetNode(Alpha::CMOVEQ, MVT::i64, Tmp1, Tmp2, Tmp3);
03580               SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03581               Result = SDOperand(ResNode, 0);
03582             }
03583             return;
03584           }
03585         }
03586 
03587         // Pattern: (select:i64 (setcc:i64 GPRC:i64:$RCOND, 0:i64, SETGE:Other), GPRC:i64:$RTRUE, GPRC:i64:$RFALSE)
03588         // Emits: (CMOVGE:i64 GPRC:i64:$RFALSE, GPRC:i64:$RTRUE, GPRC:i64:$RCOND)
03589         // Pattern complexity = 7  cost = 1
03590         if (cast<CondCodeSDNode>(N02)->get() == ISD::SETGE) {
03591           N1 = N.getOperand(1);
03592           N2 = N.getOperand(2);
03593           if (N.Val->getValueType(0) == MVT::i64 &&
03594               N00.Val->getValueType(0) == MVT::i64) {
03595             Select(Tmp1, N2);
03596             Select(Tmp2, N1);
03597             Select(Tmp3, N00);
03598             if (N.Val->hasOneUse()) {
03599               Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMOVGE, MVT::i64, Tmp1, Tmp2, Tmp3);
03600             } else {
03601               ResNode = CurDAG->getTargetNode(Alpha::CMOVGE, MVT::i64, Tmp1, Tmp2, Tmp3);
03602               SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03603               Result = SDOperand(ResNode, 0);
03604             }
03605             return;
03606           }
03607         }
03608 
03609         // Pattern: (select:i64 (setcc:i64 GPRC:i64:$RCOND, 0:i64, SETGT:Other), GPRC:i64:$RTRUE, GPRC:i64:$RFALSE)
03610         // Emits: (CMOVGT:i64 GPRC:i64:$RFALSE, GPRC:i64:$RTRUE, GPRC:i64:$RCOND)
03611         // Pattern complexity = 7  cost = 1
03612         if (cast<CondCodeSDNode>(N02)->get() == ISD::SETGT) {
03613           N1 = N.getOperand(1);
03614           N2 = N.getOperand(2);
03615           if (N.Val->getValueType(0) == MVT::i64 &&
03616               N00.Val->getValueType(0) == MVT::i64) {
03617             Select(Tmp1, N2);
03618             Select(Tmp2, N1);
03619             Select(Tmp3, N00);
03620             if (N.Val->hasOneUse()) {
03621               Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMOVGT, MVT::i64, Tmp1, Tmp2, Tmp3);
03622             } else {
03623               ResNode = CurDAG->getTargetNode(Alpha::CMOVGT, MVT::i64, Tmp1, Tmp2, Tmp3);
03624               SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03625               Result = SDOperand(ResNode, 0);
03626             }
03627             return;
03628           }
03629         }
03630 
03631         // Pattern: (select:i64 (setcc:i64 GPRC:i64:$RCOND, 0:i64, SETLE:Other), GPRC:i64:$RTRUE, GPRC:i64:$RFALSE)
03632         // Emits: (CMOVLE:i64 GPRC:i64:$RFALSE, GPRC:i64:$RTRUE, GPRC:i64:$RCOND)
03633         // Pattern complexity = 7  cost = 1
03634         if (cast<CondCodeSDNode>(N02)->get() == ISD::SETLE) {
03635           N1 = N.getOperand(1);
03636           N2 = N.getOperand(2);
03637           if (N.Val->getValueType(0) == MVT::i64 &&
03638               N00.Val->getValueType(0) == MVT::i64) {
03639             Select(Tmp1, N2);
03640             Select(Tmp2, N1);
03641             Select(Tmp3, N00);
03642             if (N.Val->hasOneUse()) {
03643               Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMOVLE, MVT::i64, Tmp1, Tmp2, Tmp3);
03644             } else {
03645               ResNode = CurDAG->getTargetNode(Alpha::CMOVLE, MVT::i64, Tmp1, Tmp2, Tmp3);
03646               SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03647               Result = SDOperand(ResNode, 0);
03648             }
03649             return;
03650           }
03651         }
03652 
03653         // Pattern: (select:i64 (setcc:i64 GPRC:i64:$RCOND, 0:i64, SETLT:Other), GPRC:i64:$RTRUE, GPRC:i64:$RFALSE)
03654         // Emits: (CMOVLT:i64 GPRC:i64:$RFALSE, GPRC:i64:$RTRUE, GPRC:i64:$RCOND)
03655         // Pattern complexity = 7  cost = 1
03656         if (cast<CondCodeSDNode>(N02)->get() == ISD::SETLT) {
03657           N1 = N.getOperand(1);
03658           N2 = N.getOperand(2);
03659           if (N.Val->getValueType(0) == MVT::i64 &&
03660               N00.Val->getValueType(0) == MVT::i64) {
03661             Select(Tmp1, N2);
03662             Select(Tmp2, N1);
03663             Select(Tmp3, N00);
03664             if (N.Val->hasOneUse()) {
03665               Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMOVLT, MVT::i64, Tmp1, Tmp2, Tmp3);
03666             } else {
03667               ResNode = CurDAG->getTargetNode(Alpha::CMOVLT, MVT::i64, Tmp1, Tmp2, Tmp3);
03668               SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03669               Result = SDOperand(ResNode, 0);
03670             }
03671             return;
03672           }
03673         }
03674 
03675         // Pattern: (select:i64 (setcc:i64 GPRC:i64:$RCOND, 0:i64, SETNE:Other), GPRC:i64:$RTRUE, GPRC:i64:$RFALSE)
03676         // Emits: (CMOVNE:i64 GPRC:i64:$RFALSE, GPRC:i64:$RTRUE, GPRC:i64:$RCOND)
03677         // Pattern complexity = 7  cost = 1
03678         if (cast<CondCodeSDNode>(N02)->get() == ISD::SETNE) {
03679           N1 = N.getOperand(1);
03680           N2 = N.getOperand(2);
03681           if (N.Val->getValueType(0) == MVT::i64 &&
03682               N00.Val->getValueType(0) == MVT::i64) {
03683             Select(Tmp1, N2);
03684             Select(Tmp2, N1);
03685             Select(Tmp3, N00);
03686             if (N.Val->hasOneUse()) {
03687               Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMOVNE, MVT::i64, Tmp1, Tmp2, Tmp3);
03688             } else {
03689               ResNode = CurDAG->getTargetNode(Alpha::CMOVNE, MVT::i64, Tmp1, Tmp2, Tmp3);
03690               SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03691               Result = SDOperand(ResNode, 0);
03692             }
03693             return;
03694           }
03695         }
03696       }
03697     }
03698   }
03699 
03700   // Pattern: (select:i64 (xor:i64 1:i64, GPRC:i64:$RCOND), GPRC:i64:$RTRUE, GPRC:i64:$RFALSE)
03701   // Emits: (CMOVLBC:i64 GPRC:i64:$RFALSE, GPRC:i64:$RTRUE, GPRC:i64:$RCOND)
03702   // Pattern complexity = 7  cost = 1
03703   if (N0.getOpcode() == ISD::XOR) {
03704     N00 = N0.getOperand(0);
03705     if (isa<ConstantSDNode>(N00)) {
03706       int64_t CN0 = cast<ConstantSDNode>(N00)->getSignExtended();
03707       if (CN0 == 1) {
03708         N01 = N0.getOperand(1);
03709         N1 = N.getOperand(1);
03710         N2 = N.getOperand(2);
03711         if (N.Val->getValueType(0) == MVT::i64) {
03712           Select(Tmp1, N2);
03713           Select(Tmp2, N1);
03714           Select(Tmp3, N01);
03715           if (N.Val->hasOneUse()) {
03716             Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMOVLBC, MVT::i64, Tmp1, Tmp2, Tmp3);
03717           } else {
03718             ResNode = CurDAG->getTargetNode(Alpha::CMOVLBC, MVT::i64, Tmp1, Tmp2, Tmp3);
03719             SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03720             Result = SDOperand(ResNode, 0);
03721           }
03722           return;
03723         }
03724       }
03725     }
03726   }
03727 
03728   // Pattern: (select:i64 (and:i64 1:i64, GPRC:i64:$RCOND), GPRC:i64:$RTRUE, GPRC:i64:$RFALSE)
03729   // Emits: (CMOVLBS:i64 GPRC:i64:$RFALSE, GPRC:i64:$RTRUE, GPRC:i64:$RCOND)
03730   // Pattern complexity = 7  cost = 1
03731   if (N0.getOpcode() == ISD::AND) {
03732     N00 = N0.getOperand(0);
03733     if (isa<ConstantSDNode>(N00)) {
03734       int64_t CN0 = cast<ConstantSDNode>(N00)->getSignExtended();
03735       if (CN0 == 1) {
03736         N01 = N0.getOperand(1);
03737         N1 = N.getOperand(1);
03738         N2 = N.getOperand(2);
03739         if (N.Val->getValueType(0) == MVT::i64) {
03740           Select(Tmp1, N2);
03741           Select(Tmp2, N1);
03742           Select(Tmp3, N01);
03743           if (N.Val->hasOneUse()) {
03744             Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMOVLBS, MVT::i64, Tmp1, Tmp2, Tmp3);
03745           } else {
03746             ResNode = CurDAG->getTargetNode(Alpha::CMOVLBS, MVT::i64, Tmp1, Tmp2, Tmp3);
03747             SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03748             Result = SDOperand(ResNode, 0);
03749           }
03750           return;
03751         }
03752       }
03753     }
03754   }
03755 
03756   // Pattern: (select:i64 GPRC:i64:$which, GPRC:i64:$src1, (imm:i64)<<P:Predicate_immUExt8>>:$src2)
03757   // Emits: (CMOVEQi:i64 GPRC:i64:$src1, (imm:i64)<<P:Predicate_immUExt8>>:$src2, GPRC:i64:$which)
03758   // Pattern complexity = 5  cost = 1
03759   {
03760     N1 = N.getOperand(1);
03761     N2 = N.getOperand(2);
03762     if (N2.getOpcode() == ISD::Constant &&
03763         Predicate_immUExt8(N2.Val)) {
03764       Select(Tmp0, N1);
03765       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N2)->getValue();
03766       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
03767       Select(Tmp2, N0);
03768       if (N.Val->hasOneUse()) {
03769         Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMOVEQi, MVT::i64, Tmp0, Tmp1, Tmp2);
03770       } else {
03771         ResNode = CurDAG->getTargetNode(Alpha::CMOVEQi, MVT::i64, Tmp0, Tmp1, Tmp2);
03772         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03773         Result = SDOperand(ResNode, 0);
03774       }
03775       return;
03776     }
03777   }
03778   if (N0.getOpcode() == ISD::SETCC) {
03779     N00 = N0.getOperand(0);
03780     N01 = N0.getOperand(1);
03781     N02 = N0.getOperand(2);
03782 
03783     // Pattern: (select:f64 (setcc:i64 F8RC:f64:$RA, F8RC:f64:$RB, SETEQ:Other), F8RC:f64:$st, F8RC:f64:$sf)
03784     // Emits: (FCMOVNET:f64 F8RC:f64:$sf, F8RC:f64:$st, (CMPTEQ:f64 F8RC:f64:$RA, F8RC:f64:$RB))
03785     // Pattern complexity = 4  cost = 2
03786     if (cast<CondCodeSDNode>(N02)->get() == ISD::SETEQ) {
03787       N1 = N.getOperand(1);
03788       N2 = N.getOperand(2);
03789       if (N.Val->getValueType(0) == MVT::f64 &&
03790           N00.Val->getValueType(0) == MVT::f64) {
03791         Select(Tmp0, N2);
03792         Select(Tmp1, N1);
03793         Select(Tmp2, N00);
03794         Select(Tmp3, N01);
03795         Tmp4 = SDOperand(CurDAG->getTargetNode(Alpha::CMPTEQ, MVT::f64, Tmp2, Tmp3), 0);
03796         if (N.Val->hasOneUse()) {
03797           Result = CurDAG->SelectNodeTo(N.Val, Alpha::FCMOVNET, MVT::f64, Tmp0, Tmp1, Tmp4);
03798         } else {
03799           ResNode = CurDAG->getTargetNode(Alpha::FCMOVNET, MVT::f64, Tmp0, Tmp1, Tmp4);
03800           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03801           Result = SDOperand(ResNode, 0);
03802         }
03803         return;
03804       }
03805     }
03806 
03807     // Pattern: (select:f64 (setcc:i64 F8RC:f64:$RA, F8RC:f64:$RB, SETNE:Other), F8RC:f64:$st, F8RC:f64:$sf)
03808     // Emits: (FCMOVEQT:f64 F8RC:f64:$sf, F8RC:f64:$st, (CMPTEQ:f64 F8RC:f64:$RA, F8RC:f64:$RB))
03809     // Pattern complexity = 4  cost = 2
03810     if (cast<CondCodeSDNode>(N02)->get() == ISD::SETNE) {
03811       N1 = N.getOperand(1);
03812       N2 = N.getOperand(2);
03813       if (N.Val->getValueType(0) == MVT::f64 &&
03814           N00.Val->getValueType(0) == MVT::f64) {
03815         Select(Tmp0, N2);
03816         Select(Tmp1, N1);
03817         Select(Tmp2, N00);
03818         Select(Tmp3, N01);
03819         Tmp4 = SDOperand(CurDAG->getTargetNode(Alpha::CMPTEQ, MVT::f64, Tmp2, Tmp3), 0);
03820         if (N.Val->hasOneUse()) {
03821           Result = CurDAG->SelectNodeTo(N.Val, Alpha::FCMOVEQT, MVT::f64, Tmp0, Tmp1, Tmp4);
03822         } else {
03823           ResNode = CurDAG->getTargetNode(Alpha::FCMOVEQT, MVT::f64, Tmp0, Tmp1, Tmp4);
03824           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03825           Result = SDOperand(ResNode, 0);
03826         }
03827         return;
03828       }
03829     }
03830 
03831     // Pattern: (select:f64 (setcc:i64 F8RC:f64:$RA, F8RC:f64:$RB, SETGT:Other), F8RC:f64:$st, F8RC:f64:$sf)
03832     // Emits: (FCMOVNET:f64 F8RC:f64:$sf, F8RC:f64:$st, (CMPTLT:f64 F8RC:f64:$RB, F8RC:f64:$RA))
03833     // Pattern complexity = 4  cost = 2
03834     if (cast<CondCodeSDNode>(N02)->get() == ISD::SETGT) {
03835       N1 = N.getOperand(1);
03836       N2 = N.getOperand(2);
03837       if (N.Val->getValueType(0) == MVT::f64 &&
03838           N00.Val->getValueType(0) == MVT::f64) {
03839         Select(Tmp0, N2);
03840         Select(Tmp1, N1);
03841         Select(Tmp2, N01);
03842         Select(Tmp3, N00);
03843         Tmp4 = SDOperand(CurDAG->getTargetNode(Alpha::CMPTLT, MVT::f64, Tmp2, Tmp3), 0);
03844         if (N.Val->hasOneUse()) {
03845           Result = CurDAG->SelectNodeTo(N.Val, Alpha::FCMOVNET, MVT::f64, Tmp0, Tmp1, Tmp4);
03846         } else {
03847           ResNode = CurDAG->getTargetNode(Alpha::FCMOVNET, MVT::f64, Tmp0, Tmp1, Tmp4);
03848           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03849           Result = SDOperand(ResNode, 0);
03850         }
03851         return;
03852       }
03853     }
03854 
03855     // Pattern: (select:f64 (setcc:i64 F8RC:f64:$RA, F8RC:f64:$RB, SETGE:Other), F8RC:f64:$st, F8RC:f64:$sf)
03856     // Emits: (FCMOVNET:f64 F8RC:f64:$sf, F8RC:f64:$st, (CMPTLE:f64 F8RC:f64:$RB, F8RC:f64:$RA))
03857     // Pattern complexity = 4  cost = 2
03858     if (cast<CondCodeSDNode>(N02)->get() == ISD::SETGE) {
03859       N1 = N.getOperand(1);
03860       N2 = N.getOperand(2);
03861       if (N.Val->getValueType(0) == MVT::f64 &&
03862           N00.Val->getValueType(0) == MVT::f64) {
03863         Select(Tmp0, N2);
03864         Select(Tmp1, N1);
03865         Select(Tmp2, N01);
03866         Select(Tmp3, N00);
03867         Tmp4 = SDOperand(CurDAG->getTargetNode(Alpha::CMPTLE, MVT::f64, Tmp2, Tmp3), 0);
03868         if (N.Val->hasOneUse()) {
03869           Result = CurDAG->SelectNodeTo(N.Val, Alpha::FCMOVNET, MVT::f64, Tmp0, Tmp1, Tmp4);
03870         } else {
03871           ResNode = CurDAG->getTargetNode(Alpha::FCMOVNET, MVT::f64, Tmp0, Tmp1, Tmp4);
03872           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03873           Result = SDOperand(ResNode, 0);
03874         }
03875         return;
03876       }
03877     }
03878 
03879     // Pattern: (select:f64 (setcc:i64 F8RC:f64:$RA, F8RC:f64:$RB, SETLT:Other), F8RC:f64:$st, F8RC:f64:$sf)
03880     // Emits: (FCMOVNET:f64 F8RC:f64:$sf, F8RC:f64:$st, (CMPTLT:f64 F8RC:f64:$RA, F8RC:f64:$RB))
03881     // Pattern complexity = 4  cost = 2
03882     if (cast<CondCodeSDNode>(N02)->get() == ISD::SETLT) {
03883       N1 = N.getOperand(1);
03884       N2 = N.getOperand(2);
03885       if (N.Val->getValueType(0) == MVT::f64 &&
03886           N00.Val->getValueType(0) == MVT::f64) {
03887         Select(Tmp0, N2);
03888         Select(Tmp1, N1);
03889         Select(Tmp2, N00);
03890         Select(Tmp3, N01);
03891         Tmp4 = SDOperand(CurDAG->getTargetNode(Alpha::CMPTLT, MVT::f64, Tmp2, Tmp3), 0);
03892         if (N.Val->hasOneUse()) {
03893           Result = CurDAG->SelectNodeTo(N.Val, Alpha::FCMOVNET, MVT::f64, Tmp0, Tmp1, Tmp4);
03894         } else {
03895           ResNode = CurDAG->getTargetNode(Alpha::FCMOVNET, MVT::f64, Tmp0, Tmp1, Tmp4);
03896           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03897           Result = SDOperand(ResNode, 0);
03898         }
03899         return;
03900       }
03901     }
03902 
03903     // Pattern: (select:f64 (setcc:i64 F8RC:f64:$RA, F8RC:f64:$RB, SETLE:Other), F8RC:f64:$st, F8RC:f64:$sf)
03904     // Emits: (FCMOVNET:f64 F8RC:f64:$sf, F8RC:f64:$st, (CMPTLE:f64 F8RC:f64:$RA, F8RC:f64:$RB))
03905     // Pattern complexity = 4  cost = 2
03906     if (cast<CondCodeSDNode>(N02)->get() == ISD::SETLE) {
03907       N1 = N.getOperand(1);
03908       N2 = N.getOperand(2);
03909       if (N.Val->getValueType(0) == MVT::f64 &&
03910           N00.Val->getValueType(0) == MVT::f64) {
03911         Select(Tmp0, N2);
03912         Select(Tmp1, N1);
03913         Select(Tmp2, N00);
03914         Select(Tmp3, N01);
03915         Tmp4 = SDOperand(CurDAG->getTargetNode(Alpha::CMPTLE, MVT::f64, Tmp2, Tmp3), 0);
03916         if (N.Val->hasOneUse()) {
03917           Result = CurDAG->SelectNodeTo(N.Val, Alpha::FCMOVNET, MVT::f64, Tmp0, Tmp1, Tmp4);
03918         } else {
03919           ResNode = CurDAG->getTargetNode(Alpha::FCMOVNET, MVT::f64, Tmp0, Tmp1, Tmp4);
03920           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03921           Result = SDOperand(ResNode, 0);
03922         }
03923         return;
03924       }
03925     }
03926 
03927     // Pattern: (select:f32 (setcc:i64 F8RC:f64:$RA, F8RC:f64:$RB, SETEQ:Other), F4RC:f32:$st, F4RC:f32:$sf)
03928     // Emits: (FCMOVNES:f32 F4RC:f32:$sf, F4RC:f32:$st, (CMPTEQ:f64 F8RC:f64:$RA, F8RC:f64:$RB))
03929     // Pattern complexity = 4  cost = 2
03930     if (cast<CondCodeSDNode>(N02)->get() == ISD::SETEQ) {
03931       N1 = N.getOperand(1);
03932       N2 = N.getOperand(2);
03933       if (N.Val->getValueType(0) == MVT::f32 &&
03934           N00.Val->getValueType(0) == MVT::f64) {
03935         Select(Tmp0, N2);
03936         Select(Tmp1, N1);
03937         Select(Tmp2, N00);
03938         Select(Tmp3, N01);
03939         Tmp4 = SDOperand(CurDAG->getTargetNode(Alpha::CMPTEQ, MVT::f64, Tmp2, Tmp3), 0);
03940         if (N.Val->hasOneUse()) {
03941           Result = CurDAG->SelectNodeTo(N.Val, Alpha::FCMOVNES, MVT::f32, Tmp0, Tmp1, Tmp4);
03942         } else {
03943           ResNode = CurDAG->getTargetNode(Alpha::FCMOVNES, MVT::f32, Tmp0, Tmp1, Tmp4);
03944           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03945           Result = SDOperand(ResNode, 0);
03946         }
03947         return;
03948       }
03949     }
03950 
03951     // Pattern: (select:f32 (setcc:i64 F8RC:f64:$RA, F8RC:f64:$RB, SETNE:Other), F4RC:f32:$st, F4RC:f32:$sf)
03952     // Emits: (FCMOVEQS:f32 F4RC:f32:$sf, F4RC:f32:$st, (CMPTEQ:f64 F8RC:f64:$RA, F8RC:f64:$RB))
03953     // Pattern complexity = 4  cost = 2
03954     if (cast<CondCodeSDNode>(N02)->get() == ISD::SETNE) {
03955       N1 = N.getOperand(1);
03956       N2 = N.getOperand(2);
03957       if (N.Val->getValueType(0) == MVT::f32 &&
03958           N00.Val->getValueType(0) == MVT::f64) {
03959         Select(Tmp0, N2);
03960         Select(Tmp1, N1);
03961         Select(Tmp2, N00);
03962         Select(Tmp3, N01);
03963         Tmp4 = SDOperand(CurDAG->getTargetNode(Alpha::CMPTEQ, MVT::f64, Tmp2, Tmp3), 0);
03964         if (N.Val->hasOneUse()) {
03965           Result = CurDAG->SelectNodeTo(N.Val, Alpha::FCMOVEQS, MVT::f32, Tmp0, Tmp1, Tmp4);
03966         } else {
03967           ResNode = CurDAG->getTargetNode(Alpha::FCMOVEQS, MVT::f32, Tmp0, Tmp1, Tmp4);
03968           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03969           Result = SDOperand(ResNode, 0);
03970         }
03971         return;
03972       }
03973     }
03974 
03975     // Pattern: (select:f32 (setcc:i64 F8RC:f64:$RA, F8RC:f64:$RB, SETGT:Other), F4RC:f32:$st, F4RC:f32:$sf)
03976     // Emits: (FCMOVNES:f32 F4RC:f32:$sf, F4RC:f32:$st, (CMPTLT:f64 F8RC:f64:$RB, F8RC:f64:$RA))
03977     // Pattern complexity = 4  cost = 2
03978     if (cast<CondCodeSDNode>(N02)->get() == ISD::SETGT) {
03979       N1 = N.getOperand(1);
03980       N2 = N.getOperand(2);
03981       if (N.Val->getValueType(0) == MVT::f32 &&
03982           N00.Val->getValueType(0) == MVT::f64) {
03983         Select(Tmp0, N2);
03984         Select(Tmp1, N1);
03985         Select(Tmp2, N01);
03986         Select(Tmp3, N00);
03987         Tmp4 = SDOperand(CurDAG->getTargetNode(Alpha::CMPTLT, MVT::f64, Tmp2, Tmp3), 0);
03988         if (N.Val->hasOneUse()) {
03989           Result = CurDAG->SelectNodeTo(N.Val, Alpha::FCMOVNES, MVT::f32, Tmp0, Tmp1, Tmp4);
03990         } else {
03991           ResNode = CurDAG->getTargetNode(Alpha::FCMOVNES, MVT::f32, Tmp0, Tmp1, Tmp4);
03992           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
03993           Result = SDOperand(ResNode, 0);
03994         }
03995         return;
03996       }
03997     }
03998 
03999     // Pattern: (select:f32 (setcc:i64 F8RC:f64:$RA, F8RC:f64:$RB, SETGE:Other), F4RC:f32:$st, F4RC:f32:$sf)
04000     // Emits: (FCMOVNES:f32 F4RC:f32:$sf, F4RC:f32:$st, (CMPTLE:f64 F8RC:f64:$RB, F8RC:f64:$RA))
04001     // Pattern complexity = 4  cost = 2
04002     if (cast<CondCodeSDNode>(N02)->get() == ISD::SETGE) {
04003       N1 = N.getOperand(1);
04004       N2 = N.getOperand(2);
04005       if (N.Val->getValueType(0) == MVT::f32 &&
04006           N00.Val->getValueType(0) == MVT::f64) {
04007         Select(Tmp0, N2);
04008         Select(Tmp1, N1);
04009         Select(Tmp2, N01);
04010         Select(Tmp3, N00);
04011         Tmp4 = SDOperand(CurDAG->getTargetNode(Alpha::CMPTLE, MVT::f64, Tmp2, Tmp3), 0);
04012         if (N.Val->hasOneUse()) {
04013           Result = CurDAG->SelectNodeTo(N.Val, Alpha::FCMOVNES, MVT::f32, Tmp0, Tmp1, Tmp4);
04014         } else {
04015           ResNode = CurDAG->getTargetNode(Alpha::FCMOVNES, MVT::f32, Tmp0, Tmp1, Tmp4);
04016           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04017           Result = SDOperand(ResNode, 0);
04018         }
04019         return;
04020       }
04021     }
04022 
04023     // Pattern: (select:f32 (setcc:i64 F8RC:f64:$RA, F8RC:f64:$RB, SETLT:Other), F4RC:f32:$st, F4RC:f32:$sf)
04024     // Emits: (FCMOVNES:f32 F4RC:f32:$sf, F4RC:f32:$st, (CMPTLT:f64 F8RC:f64:$RA, F8RC:f64:$RB))
04025     // Pattern complexity = 4  cost = 2
04026     if (cast<CondCodeSDNode>(N02)->get() == ISD::SETLT) {
04027       N1 = N.getOperand(1);
04028       N2 = N.getOperand(2);
04029       if (N.Val->getValueType(0) == MVT::f32 &&
04030           N00.Val->getValueType(0) == MVT::f64) {
04031         Select(Tmp0, N2);
04032         Select(Tmp1, N1);
04033         Select(Tmp2, N00);
04034         Select(Tmp3, N01);
04035         Tmp4 = SDOperand(CurDAG->getTargetNode(Alpha::CMPTLT, MVT::f64, Tmp2, Tmp3), 0);
04036         if (N.Val->hasOneUse()) {
04037           Result = CurDAG->SelectNodeTo(N.Val, Alpha::FCMOVNES, MVT::f32, Tmp0, Tmp1, Tmp4);
04038         } else {
04039           ResNode = CurDAG->getTargetNode(Alpha::FCMOVNES, MVT::f32, Tmp0, Tmp1, Tmp4);
04040           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04041           Result = SDOperand(ResNode, 0);
04042         }
04043         return;
04044       }
04045     }
04046 
04047     // Pattern: (select:f32 (setcc:i64 F8RC:f64:$RA, F8RC:f64:$RB, SETLE:Other), F4RC:f32:$st, F4RC:f32:$sf)
04048     // Emits: (FCMOVNES:f32 F4RC:f32:$sf, F4RC:f32:$st, (CMPTLE:f64 F8RC:f64:$RA, F8RC:f64:$RB))
04049     // Pattern complexity = 4  cost = 2
04050     if (cast<CondCodeSDNode>(N02)->get() == ISD::SETLE) {
04051       N1 = N.getOperand(1);
04052       N2 = N.getOperand(2);
04053       if (N.Val->getValueType(0) == MVT::f32 &&
04054           N00.Val->getValueType(0) == MVT::f64) {
04055         Select(Tmp0, N2);
04056         Select(Tmp1, N1);
04057         Select(Tmp2, N00);
04058         Select(Tmp3, N01);
04059         Tmp4 = SDOperand(CurDAG->getTargetNode(Alpha::CMPTLE, MVT::f64, Tmp2, Tmp3), 0);
04060         if (N.Val->hasOneUse()) {
04061           Result = CurDAG->SelectNodeTo(N.Val, Alpha::FCMOVNES, MVT::f32, Tmp0, Tmp1, Tmp4);
04062         } else {
04063           ResNode = CurDAG->getTargetNode(Alpha::FCMOVNES, MVT::f32, Tmp0, Tmp1, Tmp4);
04064           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04065           Result = SDOperand(ResNode, 0);
04066         }
04067         return;
04068       }
04069     }
04070   }
04071   N1 = N.getOperand(1);
04072   N2 = N.getOperand(2);
04073   if (N.Val->getValueType(0) == MVT::i64) {
04074 
04075     // Pattern: (select:i64 GPRC:i64:$which, GPRC:i64:$src1, GPRC:i64:$src2)
04076     // Emits: (CMOVNE:i64 GPRC:i64:$src2, GPRC:i64:$src1, GPRC:i64:$which)
04077     // Pattern complexity = 2  cost = 1
04078     {
04079       Select(Tmp0, N2);
04080       Select(Tmp1, N1);
04081       Select(Tmp2, N0);
04082       if (N.Val->hasOneUse()) {
04083         Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMOVNE, MVT::i64, Tmp0, Tmp1, Tmp2);
04084       } else {
04085         ResNode = CurDAG->getTargetNode(Alpha::CMOVNE, MVT::i64, Tmp0, Tmp1, Tmp2);
04086         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04087         Result = SDOperand(ResNode, 0);
04088       }
04089       return;
04090     }
04091 
04092     // Pattern: (select:i64 GPRC:i64:$which, GPRC:i64:$src1, GPRC:i64:$src2)
04093     // Emits: (CMOVEQ:i64 GPRC:i64:$src1, GPRC:i64:$src2, GPRC:i64:$which)
04094     // Pattern complexity = 2  cost = 1
04095     Select(Tmp0, N1);
04096     Select(Tmp1, N2);
04097     Select(Tmp2, N0);
04098     if (N.Val->hasOneUse()) {
04099       Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMOVEQ, MVT::i64, Tmp0, Tmp1, Tmp2);
04100     } else {
04101       ResNode = CurDAG->getTargetNode(Alpha::CMOVEQ, MVT::i64, Tmp0, Tmp1, Tmp2);
04102       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04103       Result = SDOperand(ResNode, 0);
04104     }
04105     return;
04106   }
04107   std::cerr << "Cannot yet select: ";
04108   N.Val->dump(CurDAG);
04109   std::cerr << '\n';
04110   abort();
04111 }
04112 
04113 void Select_setcc(SDOperand &Result, SDOperand N) {
04114   SDOperand N0(0, 0);
04115   SDOperand N00(0, 0);
04116   SDOperand N01(0, 0);
04117   SDOperand N1(0, 0);
04118   SDOperand N10(0, 0);
04119   SDOperand N11(0, 0);
04120   SDOperand N2(0, 0);
04121   SDOperand Tmp0(0, 0);
04122   SDOperand Tmp1(0, 0);
04123   SDOperand Tmp2(0, 0);
04124   SDOperand Tmp3(0, 0);
04125   SDNode *ResNode;
04126   N0 = N.getOperand(0);
04127   if (N0.getOpcode() == ISD::AND) {
04128     N00 = N0.getOperand(0);
04129 
04130     // Pattern: (setcc:i64 (and:i64 GPRC:i64:$RA, 255:i64), (and:i64 GPRC:i64:$RB, 255:i64), SETUGE:Other)
04131     // Emits: (CMPBGE:i64 GPRC:i64:$RA, GPRC:i64:$RB)
04132     // Pattern complexity = 12  cost = 1
04133     {
04134       N01 = N0.getOperand(1);
04135       if (isa<ConstantSDNode>(N01)) {
04136         int64_t CN0 = cast<ConstantSDNode>(N01)->getSignExtended();
04137         if (CN0 == 255) {
04138           N1 = N.getOperand(1);
04139           if (N1.getOpcode() == ISD::AND) {
04140             N10 = N1.getOperand(0);
04141             N11 = N1.getOperand(1);
04142             if (isa<ConstantSDNode>(N11)) {
04143               int64_t CN1 = cast<ConstantSDNode>(N11)->getSignExtended();
04144               if (CN1 == 255) {
04145                 N2 = N.getOperand(2);
04146                 if (cast<CondCodeSDNode>(N2)->get() == ISD::SETUGE) {
04147                   Select(Tmp2, N00);
04148                   Select(Tmp3, N10);
04149                   if (N.Val->hasOneUse()) {
04150                     Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPBGE, MVT::i64, Tmp2, Tmp3);
04151                   } else {
04152                     ResNode = CurDAG->getTargetNode(Alpha::CMPBGE, MVT::i64, Tmp2, Tmp3);
04153                     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04154                     Result = SDOperand(ResNode, 0);
04155                   }
04156                   return;
04157                 }
04158               }
04159             }
04160           }
04161         }
04162       }
04163     }
04164 
04165     // Pattern: (setcc:i64 (and:i64 255:i64, GPRC:i64:$RA), (and:i64 GPRC:i64:$RB, 255:i64), SETUGE:Other)
04166     // Emits: (CMPBGE:i64 GPRC:i64:$RA, GPRC:i64:$RB)
04167     // Pattern complexity = 12  cost = 1
04168     if (isa<ConstantSDNode>(N00)) {
04169       int64_t CN0 = cast<ConstantSDNode>(N00)->getSignExtended();
04170       if (CN0 == 255) {
04171         N01 = N0.getOperand(1);
04172         N1 = N.getOperand(1);
04173         if (N1.getOpcode() == ISD::AND) {
04174           N10 = N1.getOperand(0);
04175           N11 = N1.getOperand(1);
04176           if (isa<ConstantSDNode>(N11)) {
04177             int64_t CN1 = cast<ConstantSDNode>(N11)->getSignExtended();
04178             if (CN1 == 255) {
04179               N2 = N.getOperand(2);
04180               if (cast<CondCodeSDNode>(N2)->get() == ISD::SETUGE) {
04181                 Select(Tmp2, N01);
04182                 Select(Tmp3, N10);
04183                 if (N.Val->hasOneUse()) {
04184                   Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPBGE, MVT::i64, Tmp2, Tmp3);
04185                 } else {
04186                   ResNode = CurDAG->getTargetNode(Alpha::CMPBGE, MVT::i64, Tmp2, Tmp3);
04187                   SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04188                   Result = SDOperand(ResNode, 0);
04189                 }
04190                 return;
04191               }
04192             }
04193           }
04194         }
04195       }
04196     }
04197 
04198     // Pattern: (setcc:i64 (and:i64 GPRC:i64:$RA, 255:i64), (and:i64 255:i64, GPRC:i64:$RB), SETUGE:Other)
04199     // Emits: (CMPBGE:i64 GPRC:i64:$RA, GPRC:i64:$RB)
04200     // Pattern complexity = 12  cost = 1
04201     {
04202       N01 = N0.getOperand(1);
04203       if (isa<ConstantSDNode>(N01)) {
04204         int64_t CN0 = cast<ConstantSDNode>(N01)->getSignExtended();
04205         if (CN0 == 255) {
04206           N1 = N.getOperand(1);
04207           if (N1.getOpcode() == ISD::AND) {
04208             N10 = N1.getOperand(0);
04209             if (isa<ConstantSDNode>(N10)) {
04210               int64_t CN1 = cast<ConstantSDNode>(N10)->getSignExtended();
04211               if (CN1 == 255) {
04212                 N11 = N1.getOperand(1);
04213                 N2 = N.getOperand(2);
04214                 if (cast<CondCodeSDNode>(N2)->get() == ISD::SETUGE) {
04215                   Select(Tmp2, N00);
04216                   Select(Tmp3, N11);
04217                   if (N.Val->hasOneUse()) {
04218                     Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPBGE, MVT::i64, Tmp2, Tmp3);
04219                   } else {
04220                     ResNode = CurDAG->getTargetNode(Alpha::CMPBGE, MVT::i64, Tmp2, Tmp3);
04221                     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04222                     Result = SDOperand(ResNode, 0);
04223                   }
04224                   return;
04225                 }
04226               }
04227             }
04228           }
04229         }
04230       }
04231     }
04232 
04233     // Pattern: (setcc:i64 (and:i64 255:i64, GPRC:i64:$RA), (and:i64 255:i64, GPRC:i64:$RB), SETUGE:Other)
04234     // Emits: (CMPBGE:i64 GPRC:i64:$RA, GPRC:i64:$RB)
04235     // Pattern complexity = 12  cost = 1
04236     if (isa<ConstantSDNode>(N00)) {
04237       int64_t CN0 = cast<ConstantSDNode>(N00)->getSignExtended();
04238       if (CN0 == 255) {
04239         N01 = N0.getOperand(1);
04240         N1 = N.getOperand(1);
04241         if (N1.getOpcode() == ISD::AND) {
04242           N10 = N1.getOperand(0);
04243           if (isa<ConstantSDNode>(N10)) {
04244             int64_t CN1 = cast<ConstantSDNode>(N10)->getSignExtended();
04245             if (CN1 == 255) {
04246               N11 = N1.getOperand(1);
04247               N2 = N.getOperand(2);
04248               if (cast<CondCodeSDNode>(N2)->get() == ISD::SETUGE) {
04249                 Select(Tmp2, N01);
04250                 Select(Tmp3, N11);
04251                 if (N.Val->hasOneUse()) {
04252                   Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPBGE, MVT::i64, Tmp2, Tmp3);
04253                 } else {
04254                   ResNode = CurDAG->getTargetNode(Alpha::CMPBGE, MVT::i64, Tmp2, Tmp3);
04255                   SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04256                   Result = SDOperand(ResNode, 0);
04257                 }
04258                 return;
04259               }
04260             }
04261           }
04262         }
04263       }
04264     }
04265 
04266     // Pattern: (setcc:i64 (and:i64 GPRC:i64:$RA, 255:i64), (imm:i64)<<P:Predicate_immUExt8>>:$L, SETUGE:Other)
04267     // Emits: (CMPBGEi:i64 GPRC:i64:$RA, (imm:i64):$L)
04268     // Pattern complexity = 10  cost = 1
04269     {
04270       N01 = N0.getOperand(1);
04271       if (isa<ConstantSDNode>(N01)) {
04272         int64_t CN0 = cast<ConstantSDNode>(N01)->getSignExtended();
04273         if (CN0 == 255) {
04274           N1 = N.getOperand(1);
04275           if (N1.getOpcode() == ISD::Constant &&
04276               Predicate_immUExt8(N1.Val)) {
04277             N2 = N.getOperand(2);
04278             if (cast<CondCodeSDNode>(N2)->get() == ISD::SETUGE) {
04279               Select(Tmp1, N00);
04280               uint64_t Tmp2C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
04281               Tmp2 = CurDAG->getTargetConstant(Tmp2C, MVT::i64);
04282               if (N.Val->hasOneUse()) {
04283                 Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPBGEi, MVT::i64, Tmp1, Tmp2);
04284               } else {
04285                 ResNode = CurDAG->getTargetNode(Alpha::CMPBGEi, MVT::i64, Tmp1, Tmp2);
04286                 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04287                 Result = SDOperand(ResNode, 0);
04288               }
04289               return;
04290             }
04291           }
04292         }
04293       }
04294     }
04295 
04296     // Pattern: (setcc:i64 (and:i64 255:i64, GPRC:i64:$RA), (imm:i64)<<P:Predicate_immUExt8>>:$L, SETUGE:Other)
04297     // Emits: (CMPBGEi:i64 GPRC:i64:$RA, (imm:i64):$L)
04298     // Pattern complexity = 10  cost = 1
04299     if (isa<ConstantSDNode>(N00)) {
04300       int64_t CN0 = cast<ConstantSDNode>(N00)->getSignExtended();
04301       if (CN0 == 255) {
04302         N01 = N0.getOperand(1);
04303         N1 = N.getOperand(1);
04304         if (N1.getOpcode() == ISD::Constant &&
04305             Predicate_immUExt8(N1.Val)) {
04306           N2 = N.getOperand(2);
04307           if (cast<CondCodeSDNode>(N2)->get() == ISD::SETUGE) {
04308             Select(Tmp1, N01);
04309             uint64_t Tmp2C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
04310             Tmp2 = CurDAG->getTargetConstant(Tmp2C, MVT::i64);
04311             if (N.Val->hasOneUse()) {
04312               Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPBGEi, MVT::i64, Tmp1, Tmp2);
04313             } else {
04314               ResNode = CurDAG->getTargetNode(Alpha::CMPBGEi, MVT::i64, Tmp1, Tmp2);
04315               SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04316               Result = SDOperand(ResNode, 0);
04317             }
04318             return;
04319           }
04320         }
04321       }
04322     }
04323   }
04324   {
04325     N1 = N.getOperand(1);
04326     if (N1.getOpcode() == ISD::Constant &&
04327         Predicate_immUExt8(N1.Val)) {
04328       N2 = N.getOperand(2);
04329 
04330       // Pattern: (setcc:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immUExt8>>:$L, SETEQ:Other)
04331       // Emits: (CMPEQi:i64 GPRC:i64:$RA, (imm:i64):$L)
04332       // Pattern complexity = 5  cost = 1
04333       if (cast<CondCodeSDNode>(N2)->get() == ISD::SETEQ) {
04334         Select(Tmp0, N0);
04335         uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
04336         Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
04337         if (N.Val->hasOneUse()) {
04338           Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPEQi, MVT::i64, Tmp0, Tmp1);
04339         } else {
04340           ResNode = CurDAG->getTargetNode(Alpha::CMPEQi, MVT::i64, Tmp0, Tmp1);
04341           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04342           Result = SDOperand(ResNode, 0);
04343         }
04344         return;
04345       }
04346 
04347       // Pattern: (setcc:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immUExt8>>:$L, SETLE:Other)
04348       // Emits: (CMPLEi:i64 GPRC:i64:$RA, (imm:i64):$L)
04349       // Pattern complexity = 5  cost = 1
04350       if (cast<CondCodeSDNode>(N2)->get() == ISD::SETLE) {
04351         Select(Tmp0, N0);
04352         uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
04353         Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
04354         if (N.Val->hasOneUse()) {
04355           Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPLEi, MVT::i64, Tmp0, Tmp1);
04356         } else {
04357           ResNode = CurDAG->getTargetNode(Alpha::CMPLEi, MVT::i64, Tmp0, Tmp1);
04358           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04359           Result = SDOperand(ResNode, 0);
04360         }
04361         return;
04362       }
04363 
04364       // Pattern: (setcc:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immUExt8>>:$L, SETLT:Other)
04365       // Emits: (CMPLTi:i64 GPRC:i64:$RA, (imm:i64):$L)
04366       // Pattern complexity = 5  cost = 1
04367       if (cast<CondCodeSDNode>(N2)->get() == ISD::SETLT) {
04368         Select(Tmp0, N0);
04369         uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
04370         Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
04371         if (N.Val->hasOneUse()) {
04372           Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPLTi, MVT::i64, Tmp0, Tmp1);
04373         } else {
04374           ResNode = CurDAG->getTargetNode(Alpha::CMPLTi, MVT::i64, Tmp0, Tmp1);
04375           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04376           Result = SDOperand(ResNode, 0);
04377         }
04378         return;
04379       }
04380 
04381       // Pattern: (setcc:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immUExt8>>:$L, SETULE:Other)
04382       // Emits: (CMPULEi:i64 GPRC:i64:$RA, (imm:i64):$L)
04383       // Pattern complexity = 5  cost = 1
04384       if (cast<CondCodeSDNode>(N2)->get() == ISD::SETULE) {
04385         Select(Tmp0, N0);
04386         uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
04387         Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
04388         if (N.Val->hasOneUse()) {
04389           Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPULEi, MVT::i64, Tmp0, Tmp1);
04390         } else {
04391           ResNode = CurDAG->getTargetNode(Alpha::CMPULEi, MVT::i64, Tmp0, Tmp1);
04392           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04393           Result = SDOperand(ResNode, 0);
04394         }
04395         return;
04396       }
04397 
04398       // Pattern: (setcc:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immUExt8>>:$L, SETULT:Other)
04399       // Emits: (CMPULTi:i64 GPRC:i64:$RA, (imm:i64):$L)
04400       // Pattern complexity = 5  cost = 1
04401       if (cast<CondCodeSDNode>(N2)->get() == ISD::SETULT) {
04402         Select(Tmp0, N0);
04403         uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
04404         Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
04405         if (N.Val->hasOneUse()) {
04406           Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPULTi, MVT::i64, Tmp0, Tmp1);
04407         } else {
04408           ResNode = CurDAG->getTargetNode(Alpha::CMPULTi, MVT::i64, Tmp0, Tmp1);
04409           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04410           Result = SDOperand(ResNode, 0);
04411         }
04412         return;
04413       }
04414     }
04415   }
04416 
04417   // Pattern: (setcc:i64 (imm:i64)<<P:Predicate_immUExt8>>:$X, GPRC:i64:$Y, SETGE:Other)
04418   // Emits: (CMPLEi:i64 GPRC:i64:$Y, (imm:i64)<<P:Predicate_immUExt8>>:$X)
04419   // Pattern complexity = 5  cost = 1
04420   if (N0.getOpcode() == ISD::Constant &&
04421       Predicate_immUExt8(N0.Val)) {
04422     N1 = N.getOperand(1);
04423     N2 = N.getOperand(2);
04424     if (cast<CondCodeSDNode>(N2)->get() == ISD::SETGE) {
04425       Select(Tmp0, N1);
04426       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N0)->getValue();
04427       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
04428       if (N.Val->hasOneUse()) {
04429         Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPLEi, MVT::i64, Tmp0, Tmp1);
04430       } else {
04431         ResNode = CurDAG->getTargetNode(Alpha::CMPLEi, MVT::i64, Tmp0, Tmp1);
04432         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04433         Result = SDOperand(ResNode, 0);
04434       }
04435       return;
04436     }
04437   }
04438 
04439   // Pattern: (setcc:i64 GPRC:i64:$X, (imm:i64)<<P:Predicate_immUExt8>>:$Y, SETUEQ:Other)
04440   // Emits: (CMPEQi:i64 GPRC:i64:$X, (imm:i64)<<P:Predicate_immUExt8>>:$Y)
04441   // Pattern complexity = 5  cost = 1
04442   {
04443     N1 = N.getOperand(1);
04444     if (N1.getOpcode() == ISD::Constant &&
04445         Predicate_immUExt8(N1.Val)) {
04446       N2 = N.getOperand(2);
04447       if (cast<CondCodeSDNode>(N2)->get() == ISD::SETUEQ) {
04448         Select(Tmp0, N0);
04449         uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
04450         Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
04451         if (N.Val->hasOneUse()) {
04452           Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPEQi, MVT::i64, Tmp0, Tmp1);
04453         } else {
04454           ResNode = CurDAG->getTargetNode(Alpha::CMPEQi, MVT::i64, Tmp0, Tmp1);
04455           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04456           Result = SDOperand(ResNode, 0);
04457         }
04458         return;
04459       }
04460     }
04461   }
04462   if (N0.getOpcode() == ISD::Constant &&
04463       Predicate_immUExt8(N0.Val)) {
04464     N1 = N.getOperand(1);
04465     N2 = N.getOperand(2);
04466 
04467     // Pattern: (setcc:i64 (imm:i64)<<P:Predicate_immUExt8>>:$X, GPRC:i64:$Y, SETUGT:Other)
04468     // Emits: (CMPULTi:i64 GPRC:i64:$Y, (imm:i64)<<P:Predicate_immUExt8>>:$X)
04469     // Pattern complexity = 5  cost = 1
04470     if (cast<CondCodeSDNode>(N2)->get() == ISD::SETUGT) {
04471       Select(Tmp0, N1);
04472       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N0)->getValue();
04473       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
04474       if (N.Val->hasOneUse()) {
04475         Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPULTi, MVT::i64, Tmp0, Tmp1);
04476       } else {
04477         ResNode = CurDAG->getTargetNode(Alpha::CMPULTi, MVT::i64, Tmp0, Tmp1);
04478         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04479         Result = SDOperand(ResNode, 0);
04480       }
04481       return;
04482     }
04483 
04484     // Pattern: (setcc:i64 (imm:i64)<<P:Predicate_immUExt8>>:$X, GPRC:i64:$Y, SETUGE:Other)
04485     // Emits: (CMPULEi:i64 GPRC:i64:$Y, (imm:i64)<<P:Predicate_immUExt8>>:$X)
04486     // Pattern complexity = 5  cost = 1
04487     if (cast<CondCodeSDNode>(N2)->get() == ISD::SETUGE) {
04488       Select(Tmp0, N1);
04489       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N0)->getValue();
04490       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
04491       if (N.Val->hasOneUse()) {
04492         Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPULEi, MVT::i64, Tmp0, Tmp1);
04493       } else {
04494         ResNode = CurDAG->getTargetNode(Alpha::CMPULEi, MVT::i64, Tmp0, Tmp1);
04495         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04496         Result = SDOperand(ResNode, 0);
04497       }
04498       return;
04499     }
04500 
04501     // Pattern: (setcc:i64 (imm:i64)<<P:Predicate_immUExt8>>:$X, GPRC:i64:$Y, SETGT:Other)
04502     // Emits: (CMPLTi:i64 GPRC:i64:$Y, (imm:i64)<<P:Predicate_immUExt8>>:$X)
04503     // Pattern complexity = 5  cost = 1
04504     if (cast<CondCodeSDNode>(N2)->get() == ISD::SETGT) {
04505       Select(Tmp0, N1);
04506       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N0)->getValue();
04507       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
04508       if (N.Val->hasOneUse()) {
04509         Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPLTi, MVT::i64, Tmp0, Tmp1);
04510       } else {
04511         ResNode = CurDAG->getTargetNode(Alpha::CMPLTi, MVT::i64, Tmp0, Tmp1);
04512         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04513         Result = SDOperand(ResNode, 0);
04514       }
04515       return;
04516     }
04517   }
04518   N1 = N.getOperand(1);
04519   if (N1.getOpcode() == ISD::Constant &&
04520       Predicate_immUExt8(N1.Val)) {
04521     N2 = N.getOperand(2);
04522 
04523     // Pattern: (setcc:i64 GPRC:i64:$X, (imm:i64)<<P:Predicate_immUExt8>>:$Y, SETNE:Other)
04524     // Emits: (CMPEQi:i64 (CMPEQi:i64 GPRC:i64:$X, (imm:i64)<<P:Predicate_immUExt8>>:$Y), 0:i64)
04525     // Pattern complexity = 5  cost = 2
04526     if (cast<CondCodeSDNode>(N2)->get() == ISD::SETNE) {
04527       Select(Tmp0, N0);
04528       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
04529       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
04530       Tmp2 = SDOperand(CurDAG->getTargetNode(Alpha::CMPEQi, MVT::i64, Tmp0, Tmp1), 0);
04531       Tmp3 = CurDAG->getTargetConstant(0, MVT::i64);
04532       if (N.Val->hasOneUse()) {
04533         Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPEQi, MVT::i64, Tmp2, Tmp3);
04534       } else {
04535         ResNode = CurDAG->getTargetNode(Alpha::CMPEQi, MVT::i64, Tmp2, Tmp3);
04536         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04537         Result = SDOperand(ResNode, 0);
04538       }
04539       return;
04540     }
04541 
04542     // Pattern: (setcc:i64 GPRC:i64:$X, (imm:i64)<<P:Predicate_immUExt8>>:$Y, SETUNE:Other)
04543     // Emits: (CMPEQi:i64 (CMPEQ:i64 GPRC:i64:$X, (imm:i64)<<P:Predicate_immUExt8>>:$Y), 0:i64)
04544     // Pattern complexity = 5  cost = 2
04545     if (cast<CondCodeSDNode>(N2)->get() == ISD::SETUNE) {
04546       Select(Tmp0, N0);
04547       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
04548       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
04549       Tmp2 = SDOperand(CurDAG->getTargetNode(Alpha::CMPEQ, MVT::i64, Tmp0, Tmp1), 0);
04550       Tmp3 = CurDAG->getTargetConstant(0, MVT::i64);
04551       if (N.Val->hasOneUse()) {
04552         Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPEQi, MVT::i64, Tmp2, Tmp3);
04553       } else {
04554         ResNode = CurDAG->getTargetNode(Alpha::CMPEQi, MVT::i64, Tmp2, Tmp3);
04555         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04556         Result = SDOperand(ResNode, 0);
04557       }
04558       return;
04559     }
04560   }
04561   N2 = N.getOperand(2);
04562 
04563   // Pattern: (setcc:i64 GPRC:i64:$RA, GPRC:i64:$RB, SETEQ:Other)
04564   // Emits: (CMPEQ:i64 GPRC:i64:$RA, GPRC:i64:$RB)
04565   // Pattern complexity = 2  cost = 1
04566   if (cast<CondCodeSDNode>(N2)->get() == ISD::SETEQ &&
04567       N0.Val->getValueType(0) == MVT::i64) {
04568     Select(Tmp0, N0);
04569     Select(Tmp1, N1);
04570     if (N.Val->hasOneUse()) {
04571       Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPEQ, MVT::i64, Tmp0, Tmp1);
04572     } else {
04573       ResNode = CurDAG->getTargetNode(Alpha::CMPEQ, MVT::i64, Tmp0, Tmp1);
04574       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04575       Result = SDOperand(ResNode, 0);
04576     }
04577     return;
04578   }
04579 
04580   // Pattern: (setcc:i64 GPRC:i64:$RA, GPRC:i64:$RB, SETLE:Other)
04581   // Emits: (CMPLE:i64 GPRC:i64:$RA, GPRC:i64:$RB)
04582   // Pattern complexity = 2  cost = 1
04583   if (cast<CondCodeSDNode>(N2)->get() == ISD::SETLE &&
04584       N0.Val->getValueType(0) == MVT::i64) {
04585     Select(Tmp0, N0);
04586     Select(Tmp1, N1);
04587     if (N.Val->hasOneUse()) {
04588       Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPLE, MVT::i64, Tmp0, Tmp1);
04589     } else {
04590       ResNode = CurDAG->getTargetNode(Alpha::CMPLE, MVT::i64, Tmp0, Tmp1);
04591       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04592       Result = SDOperand(ResNode, 0);
04593     }
04594     return;
04595   }
04596 
04597   // Pattern: (setcc:i64 GPRC:i64:$RA, GPRC:i64:$RB, SETLT:Other)
04598   // Emits: (CMPLT:i64 GPRC:i64:$RA, GPRC:i64:$RB)
04599   // Pattern complexity = 2  cost = 1
04600   if (cast<CondCodeSDNode>(N2)->get() == ISD::SETLT &&
04601       N0.Val->getValueType(0) == MVT::i64) {
04602     Select(Tmp0, N0);
04603     Select(Tmp1, N1);
04604     if (N.Val->hasOneUse()) {
04605       Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPLT, MVT::i64, Tmp0, Tmp1);
04606     } else {
04607       ResNode = CurDAG->getTargetNode(Alpha::CMPLT, MVT::i64, Tmp0, Tmp1);
04608       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04609       Result = SDOperand(ResNode, 0);
04610     }
04611     return;
04612   }
04613 
04614   // Pattern: (setcc:i64 GPRC:i64:$RA, GPRC:i64:$RB, SETULE:Other)
04615   // Emits: (CMPULE:i64 GPRC:i64:$RA, GPRC:i64:$RB)
04616   // Pattern complexity = 2  cost = 1
04617   if (cast<CondCodeSDNode>(N2)->get() == ISD::SETULE &&
04618       N0.Val->getValueType(0) == MVT::i64) {
04619     Select(Tmp0, N0);
04620     Select(Tmp1, N1);
04621     if (N.Val->hasOneUse()) {
04622       Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPULE, MVT::i64, Tmp0, Tmp1);
04623     } else {
04624       ResNode = CurDAG->getTargetNode(Alpha::CMPULE, MVT::i64, Tmp0, Tmp1);
04625       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04626       Result = SDOperand(ResNode, 0);
04627     }
04628     return;
04629   }
04630 
04631   // Pattern: (setcc:i64 GPRC:i64:$RA, GPRC:i64:$RB, SETULT:Other)
04632   // Emits: (CMPULT:i64 GPRC:i64:$RA, GPRC:i64:$RB)
04633   // Pattern complexity = 2  cost = 1
04634   if (cast<CondCodeSDNode>(N2)->get() == ISD::SETULT &&
04635       N0.Val->getValueType(0) == MVT::i64) {
04636     Select(Tmp0, N0);
04637     Select(Tmp1, N1);
04638     if (N.Val->hasOneUse()) {
04639       Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPULT, MVT::i64, Tmp0, Tmp1);
04640     } else {
04641       ResNode = CurDAG->getTargetNode(Alpha::CMPULT, MVT::i64, Tmp0, Tmp1);
04642       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04643       Result = SDOperand(ResNode, 0);
04644     }
04645     return;
04646   }
04647 
04648   // Pattern: (setcc:i64 GPRC:i64:$X, GPRC:i64:$Y, SETGE:Other)
04649   // Emits: (CMPLE:i64 GPRC:i64:$Y, GPRC:i64:$X)
04650   // Pattern complexity = 2  cost = 1
04651   if (cast<CondCodeSDNode>(N2)->get() == ISD::SETGE &&
04652       N0.Val->getValueType(0) == MVT::i64) {
04653     Select(Tmp0, N1);
04654     Select(Tmp1, N0);
04655     if (N.Val->hasOneUse()) {
04656       Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPLE, MVT::i64, Tmp0, Tmp1);
04657     } else {
04658       ResNode = CurDAG->getTargetNode(Alpha::CMPLE, MVT::i64, Tmp0, Tmp1);
04659       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04660       Result = SDOperand(ResNode, 0);
04661     }
04662     return;
04663   }
04664 
04665   // Pattern: (setcc:i64 GPRC:i64:$X, GPRC:i64:$Y, SETUEQ:Other)
04666   // Emits: (CMPEQ:i64 GPRC:i64:$X, GPRC:i64:$Y)
04667   // Pattern complexity = 2  cost = 1
04668   if (cast<CondCodeSDNode>(N2)->get() == ISD::SETUEQ &&
04669       N0.Val->getValueType(0) == MVT::i64) {
04670     Select(Tmp0, N0);
04671     Select(Tmp1, N1);
04672     if (N.Val->hasOneUse()) {
04673       Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPEQ, MVT::i64, Tmp0, Tmp1);
04674     } else {
04675       ResNode = CurDAG->getTargetNode(Alpha::CMPEQ, MVT::i64, Tmp0, Tmp1);
04676       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04677       Result = SDOperand(ResNode, 0);
04678     }
04679     return;
04680   }
04681 
04682   // Pattern: (setcc:i64 GPRC:i64:$X, GPRC:i64:$Y, SETUGT:Other)
04683   // Emits: (CMPULT:i64 GPRC:i64:$Y, GPRC:i64:$X)
04684   // Pattern complexity = 2  cost = 1
04685   if (cast<CondCodeSDNode>(N2)->get() == ISD::SETUGT &&
04686       N0.Val->getValueType(0) == MVT::i64) {
04687     Select(Tmp0, N1);
04688     Select(Tmp1, N0);
04689     if (N.Val->hasOneUse()) {
04690       Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPULT, MVT::i64, Tmp0, Tmp1);
04691     } else {
04692       ResNode = CurDAG->getTargetNode(Alpha::CMPULT, MVT::i64, Tmp0, Tmp1);
04693       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04694       Result = SDOperand(ResNode, 0);
04695     }
04696     return;
04697   }
04698 
04699   // Pattern: (setcc:i64 GPRC:i64:$X, GPRC:i64:$Y, SETUGE:Other)
04700   // Emits: (CMPULE:i64 GPRC:i64:$Y, GPRC:i64:$X)
04701   // Pattern complexity = 2  cost = 1
04702   if (cast<CondCodeSDNode>(N2)->get() == ISD::SETUGE &&
04703       N0.Val->getValueType(0) == MVT::i64) {
04704     Select(Tmp0, N1);
04705     Select(Tmp1, N0);
04706     if (N.Val->hasOneUse()) {
04707       Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPULE, MVT::i64, Tmp0, Tmp1);
04708     } else {
04709       ResNode = CurDAG->getTargetNode(Alpha::CMPULE, MVT::i64, Tmp0, Tmp1);
04710       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04711       Result = SDOperand(ResNode, 0);
04712     }
04713     return;
04714   }
04715 
04716   // Pattern: (setcc:i64 GPRC:i64:$X, GPRC:i64:$Y, SETGT:Other)
04717   // Emits: (CMPLT:i64 GPRC:i64:$Y, GPRC:i64:$X)
04718   // Pattern complexity = 2  cost = 1
04719   if (cast<CondCodeSDNode>(N2)->get() == ISD::SETGT &&
04720       N0.Val->getValueType(0) == MVT::i64) {
04721     Select(Tmp0, N1);
04722     Select(Tmp1, N0);
04723     if (N.Val->hasOneUse()) {
04724       Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPLT, MVT::i64, Tmp0, Tmp1);
04725     } else {
04726       ResNode = CurDAG->getTargetNode(Alpha::CMPLT, MVT::i64, Tmp0, Tmp1);
04727       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04728       Result = SDOperand(ResNode, 0);
04729     }
04730     return;
04731   }
04732 
04733   // Pattern: (setcc:i64 GPRC:i64:$X, GPRC:i64:$Y, SETNE:Other)
04734   // Emits: (CMPEQi:i64 (CMPEQ:i64 GPRC:i64:$X, GPRC:i64:$Y), 0:i64)
04735   // Pattern complexity = 2  cost = 2
04736   if (cast<CondCodeSDNode>(N2)->get() == ISD::SETNE &&
04737       N0.Val->getValueType(0) == MVT::i64) {
04738     Select(Tmp0, N0);
04739     Select(Tmp1, N1);
04740     Tmp2 = SDOperand(CurDAG->getTargetNode(Alpha::CMPEQ, MVT::i64, Tmp0, Tmp1), 0);
04741     Tmp3 = CurDAG->getTargetConstant(0, MVT::i64);
04742     if (N.Val->hasOneUse()) {
04743       Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPEQi, MVT::i64, Tmp2, Tmp3);
04744     } else {
04745       ResNode = CurDAG->getTargetNode(Alpha::CMPEQi, MVT::i64, Tmp2, Tmp3);
04746       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04747       Result = SDOperand(ResNode, 0);
04748     }
04749     return;
04750   }
04751 
04752   // Pattern: (setcc:i64 GPRC:i64:$X, GPRC:i64:$Y, SETUNE:Other)
04753   // Emits: (CMPEQi:i64 (CMPEQ:i64 GPRC:i64:$X, GPRC:i64:$Y), 0:i64)
04754   // Pattern complexity = 2  cost = 2
04755   if (cast<CondCodeSDNode>(N2)->get() == ISD::SETUNE &&
04756       N0.Val->getValueType(0) == MVT::i64) {
04757     Select(Tmp0, N0);
04758     Select(Tmp1, N1);
04759     Tmp2 = SDOperand(CurDAG->getTargetNode(Alpha::CMPEQ, MVT::i64, Tmp0, Tmp1), 0);
04760     Tmp3 = CurDAG->getTargetConstant(0, MVT::i64);
04761     if (N.Val->hasOneUse()) {
04762       Result = CurDAG->SelectNodeTo(N.Val, Alpha::CMPEQi, MVT::i64, Tmp2, Tmp3);
04763     } else {
04764       ResNode = CurDAG->getTargetNode(Alpha::CMPEQi, MVT::i64, Tmp2, Tmp3);
04765       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04766       Result = SDOperand(ResNode, 0);
04767     }
04768     return;
04769   }
04770   std::cerr << "Cannot yet select: ";
04771   N.Val->dump(CurDAG);
04772   std::cerr << '\n';
04773   abort();
04774 }
04775 
04776 void Select_sext_inreg(SDOperand &Result, SDOperand N) {
04777   SDOperand N0(0, 0);
04778   SDOperand N00(0, 0);
04779   SDOperand N000(0, 0);
04780   SDOperand N001(0, 0);
04781   SDOperand N01(0, 0);
04782   SDOperand N010(0, 0);
04783   SDOperand N011(0, 0);
04784   SDOperand N1(0, 0);
04785   SDOperand Tmp0(0, 0);
04786   SDOperand Tmp1(0, 0);
04787   SDOperand Tmp2(0, 0);
04788   SDOperand Tmp3(0, 0);
04789   SDNode *ResNode;
04790   N0 = N.getOperand(0);
04791 
04792   // Pattern: (sext_inreg:i64 (add:i64 (shl:i64 GPRC:i64:$RA, 2:i64), (imm:i64)<<P:Predicate_immUExt8>>:$L), i32:Other)
04793   // Emits: (S4ADDLi:i64 GPRC:i64:$RA, (imm:i64):$L)
04794   // Pattern complexity = 12  cost = 1
04795   if (N0.getOpcode() == ISD::ADD) {
04796     N00 = N0.getOperand(0);
04797     if (N00.getOpcode() == ISD::SHL) {
04798       N000 = N00.getOperand(0);
04799       N001 = N00.getOperand(1);
04800       if (isa<ConstantSDNode>(N001)) {
04801         int64_t CN0 = cast<ConstantSDNode>(N001)->getSignExtended();
04802         if (CN0 == 2) {
04803           N01 = N0.getOperand(1);
04804           if (N01.getOpcode() == ISD::Constant &&
04805               Predicate_immUExt8(N01.Val)) {
04806             N1 = N.getOperand(1);
04807             if (cast<VTSDNode>(N1)->getVT() == MVT::i32) {
04808               Select(Tmp1, N000);
04809               uint64_t Tmp2C = (uint64_t)cast<ConstantSDNode>(N01)->getValue();
04810               Tmp2 = CurDAG->getTargetConstant(Tmp2C, MVT::i64);
04811               if (N.Val->hasOneUse()) {
04812                 Result = CurDAG->SelectNodeTo(N.Val, Alpha::S4ADDLi, MVT::i64, Tmp1, Tmp2);
04813               } else {
04814                 ResNode = CurDAG->getTargetNode(Alpha::S4ADDLi, MVT::i64, Tmp1, Tmp2);
04815                 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04816                 Result = SDOperand(ResNode, 0);
04817               }
04818               return;
04819             }
04820           }
04821         }
04822       }
04823     }
04824   }
04825 
04826   // Pattern: (sext_inreg:i64 (sub:i64 (shl:i64 GPRC:i64:$RA, 2:i64), (imm:i64)<<P:Predicate_immUExt8>>:$L), i32:Other)
04827   // Emits: (S4SUBLi:i64 GPRC:i64:$RA, (imm:i64):$L)
04828   // Pattern complexity = 12  cost = 1
04829   if (N0.getOpcode() == ISD::SUB) {
04830     N00 = N0.getOperand(0);
04831     if (N00.getOpcode() == ISD::SHL) {
04832       N000 = N00.getOperand(0);
04833       N001 = N00.getOperand(1);
04834       if (isa<ConstantSDNode>(N001)) {
04835         int64_t CN0 = cast<ConstantSDNode>(N001)->getSignExtended();
04836         if (CN0 == 2) {
04837           N01 = N0.getOperand(1);
04838           if (N01.getOpcode() == ISD::Constant &&
04839               Predicate_immUExt8(N01.Val)) {
04840             N1 = N.getOperand(1);
04841             if (cast<VTSDNode>(N1)->getVT() == MVT::i32) {
04842               Select(Tmp1, N000);
04843               uint64_t Tmp2C = (uint64_t)cast<ConstantSDNode>(N01)->getValue();
04844               Tmp2 = CurDAG->getTargetConstant(Tmp2C, MVT::i64);
04845               if (N.Val->hasOneUse()) {
04846                 Result = CurDAG->SelectNodeTo(N.Val, Alpha::S4SUBLi, MVT::i64, Tmp1, Tmp2);
04847               } else {
04848                 ResNode = CurDAG->getTargetNode(Alpha::S4SUBLi, MVT::i64, Tmp1, Tmp2);
04849                 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04850                 Result = SDOperand(ResNode, 0);
04851               }
04852               return;
04853             }
04854           }
04855         }
04856       }
04857     }
04858   }
04859   if (N0.getOpcode() == ISD::ADD) {
04860     N00 = N0.getOperand(0);
04861     if (N00.getOpcode() == ISD::SHL) {
04862       N000 = N00.getOperand(0);
04863       N001 = N00.getOperand(1);
04864       if (isa<ConstantSDNode>(N001)) {
04865         int64_t CN0 = cast<ConstantSDNode>(N001)->getSignExtended();
04866         if (CN0 == 3) {
04867           N01 = N0.getOperand(1);
04868           if (N01.getOpcode() == ISD::Constant) {
04869 
04870             // Pattern: (sext_inreg:i64 (add:i64 (shl:i64 GPRC:i64:$RA, 3:i64), (imm:i64)<<P:Predicate_immUExt8>>:$L), i32:Other)
04871             // Emits: (S8ADDLi:i64 GPRC:i64:$RA, (imm:i64):$L)
04872             // Pattern complexity = 12  cost = 1
04873             if (Predicate_immUExt8(N01.Val)) {
04874               N1 = N.getOperand(1);
04875               if (cast<VTSDNode>(N1)->getVT() == MVT::i32) {
04876                 Select(Tmp1, N000);
04877                 uint64_t Tmp2C = (uint64_t)cast<ConstantSDNode>(N01)->getValue();
04878                 Tmp2 = CurDAG->getTargetConstant(Tmp2C, MVT::i64);
04879                 if (N.Val->hasOneUse()) {
04880                   Result = CurDAG->SelectNodeTo(N.Val, Alpha::S8ADDLi, MVT::i64, Tmp1, Tmp2);
04881                 } else {
04882                   ResNode = CurDAG->getTargetNode(Alpha::S8ADDLi, MVT::i64, Tmp1, Tmp2);
04883                   SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04884                   Result = SDOperand(ResNode, 0);
04885                 }
04886                 return;
04887               }
04888             }
04889 
04890             // Pattern: (sext_inreg:i64 (add:i64 (shl:i64 GPRC:i64:$RA, 3:i64), (imm:i64)<<P:Predicate_immUExt8neg>><<X:negX>>:$L), i32:Other)
04891             // Emits: (S8SUBLi:i64 GPRC:i64:$RA, (negX:i64 (imm:i64):$L))
04892             // Pattern complexity = 12  cost = 1
04893             if (Predicate_immUExt8neg(N01.Val)) {
04894               N1 = N.getOperand(1);
04895               if (cast<VTSDNode>(N1)->getVT() == MVT::i32) {
04896                 Select(Tmp1, N000);
04897                 uint64_t Tmp2C = (uint64_t)cast<ConstantSDNode>(N01)->getValue();
04898                 Tmp2 = CurDAG->getTargetConstant(Tmp2C, MVT::i64);
04899                 Tmp3 = Transform_negX(Tmp2.Val);
04900                 if (N.Val->hasOneUse()) {
04901                   Result = CurDAG->SelectNodeTo(N.Val, Alpha::S8SUBLi, MVT::i64, Tmp1, Tmp3);
04902                 } else {
04903                   ResNode = CurDAG->getTargetNode(Alpha::S8SUBLi, MVT::i64, Tmp1, Tmp3);
04904                   SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04905                   Result = SDOperand(ResNode, 0);
04906                 }
04907                 return;
04908               }
04909             }
04910           }
04911         }
04912 
04913         // Pattern: (sext_inreg:i64 (add:i64 (shl:i64 GPRC:i64:$RA, 2:i64), GPRC:i64:$RB), i32:Other)
04914         // Emits: (S4ADDL:i64 GPRC:i64:$RA, GPRC:i64:$RB)
04915         // Pattern complexity = 9  cost = 1
04916         if (CN0 == 2) {
04917           N01 = N0.getOperand(1);
04918           N1 = N.getOperand(1);
04919           if (cast<VTSDNode>(N1)->getVT() == MVT::i32) {
04920             Select(Tmp1, N000);
04921             Select(Tmp2, N01);
04922             if (N.Val->hasOneUse()) {
04923               Result = CurDAG->SelectNodeTo(N.Val, Alpha::S4ADDL, MVT::i64, Tmp1, Tmp2);
04924             } else {
04925               ResNode = CurDAG->getTargetNode(Alpha::S4ADDL, MVT::i64, Tmp1, Tmp2);
04926               SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04927               Result = SDOperand(ResNode, 0);
04928             }
04929             return;
04930           }
04931         }
04932       }
04933     }
04934   }
04935 
04936   // Pattern: (sext_inreg:i64 (sub:i64 (shl:i64 GPRC:i64:$RA, 2:i64), GPRC:i64:$RB), i32:Other)
04937   // Emits: (S4SUBL:i64 GPRC:i64:$RA, GPRC:i64:$RB)
04938   // Pattern complexity = 9  cost = 1
04939   if (N0.getOpcode() == ISD::SUB) {
04940     N00 = N0.getOperand(0);
04941     if (N00.getOpcode() == ISD::SHL) {
04942       N000 = N00.getOperand(0);
04943       N001 = N00.getOperand(1);
04944       if (isa<ConstantSDNode>(N001)) {
04945         int64_t CN0 = cast<ConstantSDNode>(N001)->getSignExtended();
04946         if (CN0 == 2) {
04947           N01 = N0.getOperand(1);
04948           N1 = N.getOperand(1);
04949           if (cast<VTSDNode>(N1)->getVT() == MVT::i32) {
04950             Select(Tmp1, N000);
04951             Select(Tmp2, N01);
04952             if (N.Val->hasOneUse()) {
04953               Result = CurDAG->SelectNodeTo(N.Val, Alpha::S4SUBL, MVT::i64, Tmp1, Tmp2);
04954             } else {
04955               ResNode = CurDAG->getTargetNode(Alpha::S4SUBL, MVT::i64, Tmp1, Tmp2);
04956               SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04957               Result = SDOperand(ResNode, 0);
04958             }
04959             return;
04960           }
04961         }
04962       }
04963     }
04964   }
04965 
04966   // Pattern: (sext_inreg:i64 (add:i64 (shl:i64 GPRC:i64:$RA, 3:i64), GPRC:i64:$RB), i32:Other)
04967   // Emits: (S8ADDL:i64 GPRC:i64:$RA, GPRC:i64:$RB)
04968   // Pattern complexity = 9  cost = 1
04969   if (N0.getOpcode() == ISD::ADD) {
04970     N00 = N0.getOperand(0);
04971     if (N00.getOpcode() == ISD::SHL) {
04972       N000 = N00.getOperand(0);
04973       N001 = N00.getOperand(1);
04974       if (isa<ConstantSDNode>(N001)) {
04975         int64_t CN0 = cast<ConstantSDNode>(N001)->getSignExtended();
04976         if (CN0 == 3) {
04977           N01 = N0.getOperand(1);
04978           N1 = N.getOperand(1);
04979           if (cast<VTSDNode>(N1)->getVT() == MVT::i32) {
04980             Select(Tmp1, N000);
04981             Select(Tmp2, N01);
04982             if (N.Val->hasOneUse()) {
04983               Result = CurDAG->SelectNodeTo(N.Val, Alpha::S8ADDL, MVT::i64, Tmp1, Tmp2);
04984             } else {
04985               ResNode = CurDAG->getTargetNode(Alpha::S8ADDL, MVT::i64, Tmp1, Tmp2);
04986               SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
04987               Result = SDOperand(ResNode, 0);
04988             }
04989             return;
04990           }
04991         }
04992       }
04993     }
04994   }
04995 
04996   // Pattern: (sext_inreg:i64 (sub:i64 (shl:i64 GPRC:i64:$RA, 3:i64), GPRC:i64:$RB), i32:Other)
04997   // Emits: (S8SUBL:i64 GPRC:i64:$RA, GPRC:i64:$RB)
04998   // Pattern complexity = 9  cost = 1
04999   if (N0.getOpcode() == ISD::SUB) {
05000     N00 = N0.getOperand(0);
05001     if (N00.getOpcode() == ISD::SHL) {
05002       N000 = N00.getOperand(0);
05003       N001 = N00.getOperand(1);
05004       if (isa<ConstantSDNode>(N001)) {
05005         int64_t CN0 = cast<ConstantSDNode>(N001)->getSignExtended();
05006         if (CN0 == 3) {
05007           N01 = N0.getOperand(1);
05008           N1 = N.getOperand(1);
05009           if (cast<VTSDNode>(N1)->getVT() == MVT::i32) {
05010             Select(Tmp1, N000);
05011             Select(Tmp2, N01);
05012             if (N.Val->hasOneUse()) {
05013               Result = CurDAG->SelectNodeTo(N.Val, Alpha::S8SUBL, MVT::i64, Tmp1, Tmp2);
05014             } else {
05015               ResNode = CurDAG->getTargetNode(Alpha::S8SUBL, MVT::i64, Tmp1, Tmp2);
05016               SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05017               Result = SDOperand(ResNode, 0);
05018             }
05019             return;
05020           }
05021         }
05022       }
05023     }
05024   }
05025   if (N0.getOpcode() == ISD::ADD) {
05026     N00 = N0.getOperand(0);
05027     N01 = N0.getOperand(1);
05028     if (N01.getOpcode() == ISD::SHL) {
05029       N010 = N01.getOperand(0);
05030       N011 = N01.getOperand(1);
05031       if (isa<ConstantSDNode>(N011)) {
05032         int64_t CN0 = cast<ConstantSDNode>(N011)->getSignExtended();
05033 
05034         // Pattern: (sext_inreg:i64 (add:i64 GPRC:i64:$RB, (shl:i64 GPRC:i64:$RA, 2:i64)), i32:Other)
05035         // Emits: (S4ADDL:i64 GPRC:i64:$RA, GPRC:i64:$RB)
05036         // Pattern complexity = 9  cost = 1
05037         if (CN0 == 2) {
05038           N1 = N.getOperand(1);
05039           if (cast<VTSDNode>(N1)->getVT() == MVT::i32) {
05040             Select(Tmp1, N010);
05041             Select(Tmp2, N00);
05042             if (N.Val->hasOneUse()) {
05043               Result = CurDAG->SelectNodeTo(N.Val, Alpha::S4ADDL, MVT::i64, Tmp1, Tmp2);
05044             } else {
05045               ResNode = CurDAG->getTargetNode(Alpha::S4ADDL, MVT::i64, Tmp1, Tmp2);
05046               SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05047               Result = SDOperand(ResNode, 0);
05048             }
05049             return;
05050           }
05051         }
05052 
05053         // Pattern: (sext_inreg:i64 (add:i64 GPRC:i64:$RB, (shl:i64 GPRC:i64:$RA, 3:i64)), i32:Other)
05054         // Emits: (S8ADDL:i64 GPRC:i64:$RA, GPRC:i64:$RB)
05055         // Pattern complexity = 9  cost = 1
05056         if (CN0 == 3) {
05057           N1 = N.getOperand(1);
05058           if (cast<VTSDNode>(N1)->getVT() == MVT::i32) {
05059             Select(Tmp1, N010);
05060             Select(Tmp2, N00);
05061             if (N.Val->hasOneUse()) {
05062               Result = CurDAG->SelectNodeTo(N.Val, Alpha::S8ADDL, MVT::i64, Tmp1, Tmp2);
05063             } else {
05064               ResNode = CurDAG->getTargetNode(Alpha::S8ADDL, MVT::i64, Tmp1, Tmp2);
05065               SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05066               Result = SDOperand(ResNode, 0);
05067             }
05068             return;
05069           }
05070         }
05071       }
05072     }
05073 
05074     // Pattern: (sext_inreg:i64 (add:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immUExt8>>:$L), i32:Other)
05075     // Emits: (ADDLi:i64 GPRC:i64:$RA, (imm:i64):$L)
05076     // Pattern complexity = 7  cost = 1
05077     if (N01.getOpcode() == ISD::Constant &&
05078         Predicate_immUExt8(N01.Val)) {
05079       N1 = N.getOperand(1);
05080       if (cast<VTSDNode>(N1)->getVT() == MVT::i32) {
05081         Select(Tmp0, N00);
05082         uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N01)->getValue();
05083         Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
05084         if (N.Val->hasOneUse()) {
05085           Result = CurDAG->SelectNodeTo(N.Val, Alpha::ADDLi, MVT::i64, Tmp0, Tmp1);
05086         } else {
05087           ResNode = CurDAG->getTargetNode(Alpha::ADDLi, MVT::i64, Tmp0, Tmp1);
05088           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05089           Result = SDOperand(ResNode, 0);
05090         }
05091         return;
05092       }
05093     }
05094   }
05095 
05096   // Pattern: (sext_inreg:i64 (mul:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immUExt8>>:$L), i32:Other)
05097   // Emits: (MULLi:i64 GPRC:i64:$RA, (imm:i64):$L)
05098   // Pattern complexity = 7  cost = 1
05099   if (N0.getOpcode() == ISD::MUL) {
05100     N00 = N0.getOperand(0);
05101     N01 = N0.getOperand(1);
05102     if (N01.getOpcode() == ISD::Constant &&
05103         Predicate_immUExt8(N01.Val)) {
05104       N1 = N.getOperand(1);
05105       if (cast<VTSDNode>(N1)->getVT() == MVT::i32) {
05106         Select(Tmp0, N00);
05107         uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N01)->getValue();
05108         Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
05109         if (N.Val->hasOneUse()) {
05110           Result = CurDAG->SelectNodeTo(N.Val, Alpha::MULLi, MVT::i64, Tmp0, Tmp1);
05111         } else {
05112           ResNode = CurDAG->getTargetNode(Alpha::MULLi, MVT::i64, Tmp0, Tmp1);
05113           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05114           Result = SDOperand(ResNode, 0);
05115         }
05116         return;
05117       }
05118     }
05119   }
05120   if (N0.getOpcode() == ISD::ADD) {
05121     N00 = N0.getOperand(0);
05122     N01 = N0.getOperand(1);
05123 
05124     // Pattern: (sext_inreg:i64 (add:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immUExt8neg>><<X:negX>>:$L), i32:Other)
05125     // Emits: (SUBLi:i64 GPRC:i64:$RA, (negX:i64 (imm:i64):$L))
05126     // Pattern complexity = 7  cost = 1
05127     if (N01.getOpcode() == ISD::Constant &&
05128         Predicate_immUExt8neg(N01.Val)) {
05129       N1 = N.getOperand(1);
05130       if (cast<VTSDNode>(N1)->getVT() == MVT::i32) {
05131         Select(Tmp0, N00);
05132         uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N01)->getValue();
05133         Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
05134         Tmp2 = Transform_negX(Tmp1.Val);
05135         if (N.Val->hasOneUse()) {
05136           Result = CurDAG->SelectNodeTo(N.Val, Alpha::SUBLi, MVT::i64, Tmp0, Tmp2);
05137         } else {
05138           ResNode = CurDAG->getTargetNode(Alpha::SUBLi, MVT::i64, Tmp0, Tmp2);
05139           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05140           Result = SDOperand(ResNode, 0);
05141         }
05142         return;
05143       }
05144     }
05145 
05146     // Pattern: (sext_inreg:i64 (add:i64 GPRC:i64:$RA, GPRC:i64:$RB), i32:Other)
05147     // Emits: (ADDL:i64 GPRC:i64:$RA, GPRC:i64:$RB)
05148     // Pattern complexity = 4  cost = 1
05149     N1 = N.getOperand(1);
05150     if (cast<VTSDNode>(N1)->getVT() == MVT::i32) {
05151       Select(Tmp0, N00);
05152       Select(Tmp1, N01);
05153       if (N.Val->hasOneUse()) {
05154         Result = CurDAG->SelectNodeTo(N.Val, Alpha::ADDL, MVT::i64, Tmp0, Tmp1);
05155       } else {
05156         ResNode = CurDAG->getTargetNode(Alpha::ADDL, MVT::i64, Tmp0, Tmp1);
05157         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05158         Result = SDOperand(ResNode, 0);
05159       }
05160       return;
05161     }
05162   }
05163 
05164   // Pattern: (sext_inreg:i64 (mul:i64 GPRC:i64:$RA, GPRC:i64:$RB), i32:Other)
05165   // Emits: (MULL:i64 GPRC:i64:$RA, GPRC:i64:$RB)
05166   // Pattern complexity = 4  cost = 1
05167   if (N0.getOpcode() == ISD::MUL) {
05168     N00 = N0.getOperand(0);
05169     N01 = N0.getOperand(1);
05170     N1 = N.getOperand(1);
05171     if (cast<VTSDNode>(N1)->getVT() == MVT::i32) {
05172       Select(Tmp0, N00);
05173       Select(Tmp1, N01);
05174       if (N.Val->hasOneUse()) {
05175         Result = CurDAG->SelectNodeTo(N.Val, Alpha::MULL, MVT::i64, Tmp0, Tmp1);
05176       } else {
05177         ResNode = CurDAG->getTargetNode(Alpha::MULL, MVT::i64, Tmp0, Tmp1);
05178         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05179         Result = SDOperand(ResNode, 0);
05180       }
05181       return;
05182     }
05183   }
05184 
05185   // Pattern: (sext_inreg:i64 (sub:i64 GPRC:i64:$RA, GPRC:i64:$RB), i32:Other)
05186   // Emits: (SUBL:i64 GPRC:i64:$RA, GPRC:i64:$RB)
05187   // Pattern complexity = 4  cost = 1
05188   if (N0.getOpcode() == ISD::SUB) {
05189     N00 = N0.getOperand(0);
05190     N01 = N0.getOperand(1);
05191     N1 = N.getOperand(1);
05192     if (cast<VTSDNode>(N1)->getVT() == MVT::i32) {
05193       Select(Tmp0, N00);
05194       Select(Tmp1, N01);
05195       if (N.Val->hasOneUse()) {
05196         Result = CurDAG->SelectNodeTo(N.Val, Alpha::SUBL, MVT::i64, Tmp0, Tmp1);
05197       } else {
05198         ResNode = CurDAG->getTargetNode(Alpha::SUBL, MVT::i64, Tmp0, Tmp1);
05199         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05200         Result = SDOperand(ResNode, 0);
05201       }
05202       return;
05203     }
05204   }
05205   N1 = N.getOperand(1);
05206 
05207   // Pattern: (sext_inreg:i64 GPRC:i64:$RB, i8:Other)
05208   // Emits: (SEXTB:i64 GPRC:i64:$RB)
05209   // Pattern complexity = 2  cost = 1
05210   if (cast<VTSDNode>(N1)->getVT() == MVT::i8) {
05211     Select(Tmp0, N0);
05212     if (N.Val->hasOneUse()) {
05213       Result = CurDAG->SelectNodeTo(N.Val, Alpha::SEXTB, MVT::i64, Tmp0);
05214     } else {
05215       ResNode = CurDAG->getTargetNode(Alpha::SEXTB, MVT::i64, Tmp0);
05216       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05217       Result = SDOperand(ResNode, 0);
05218     }
05219     return;
05220   }
05221 
05222   // Pattern: (sext_inreg:i64 GPRC:i64:$RB, i16:Other)
05223   // Emits: (SEXTW:i64 GPRC:i64:$RB)
05224   // Pattern complexity = 2  cost = 1
05225   if (cast<VTSDNode>(N1)->getVT() == MVT::i16) {
05226     Select(Tmp0, N0);
05227     if (N.Val->hasOneUse()) {
05228       Result = CurDAG->SelectNodeTo(N.Val, Alpha::SEXTW, MVT::i64, Tmp0);
05229     } else {
05230       ResNode = CurDAG->getTargetNode(Alpha::SEXTW, MVT::i64, Tmp0);
05231       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05232       Result = SDOperand(ResNode, 0);
05233     }
05234     return;
05235   }
05236 
05237   // Pattern: (sext_inreg:i64 GPRC:i64:$RB, i32:Other)
05238   // Emits: (ADDLi:i64 GPRC:i64:$RB, 0:i64)
05239   // Pattern complexity = 2  cost = 1
05240   if (cast<VTSDNode>(N1)->getVT() == MVT::i32) {
05241     Select(Tmp0, N0);
05242     Tmp1 = CurDAG->getTargetConstant(0, MVT::i64);
05243     if (N.Val->hasOneUse()) {
05244       Result = CurDAG->SelectNodeTo(N.Val, Alpha::ADDLi, MVT::i64, Tmp0, Tmp1);
05245     } else {
05246       ResNode = CurDAG->getTargetNode(Alpha::ADDLi, MVT::i64, Tmp0, Tmp1);
05247       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05248       Result = SDOperand(ResNode, 0);
05249     }
05250     return;
05251   }
05252   std::cerr << "Cannot yet select: ";
05253   N.Val->dump(CurDAG);
05254   std::cerr << '\n';
05255   abort();
05256 }
05257 
05258 void Select_sextld(SDOperand &Result, SDOperand N) {
05259   if (N.ResNo == 1 && N.getValue(0).hasOneUse()) {
05260     SDOperand Dummy = CurDAG->getNode(ISD::HANDLENODE, MVT::Other, N);
05261     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, Dummy.Val, 0);
05262     SelectionDAG::InsertISelMapEntry(HandleMap, N.Val, 1, Dummy.Val, 0);
05263     Result = Dummy;
05264     return;
05265   }
05266   SDOperand Chain(0, 0);
05267   SDOperand N1(0, 0);
05268   SDOperand N10(0, 0);
05269   SDOperand N11(0, 0);
05270   SDOperand N2(0, 0);
05271   SDOperand N3(0, 0);
05272   SDOperand Tmp0(0, 0);
05273   SDOperand Tmp1(0, 0);
05274   SDNode *ResNode;
05275   Chain = N.getOperand(0);
05276   N1 = N.getOperand(1);
05277 
05278   // Pattern: (sextld:i64 (add:i64 GPRC:i64:$RB, (imm:i64)<<P:Predicate_immSExt16>>:$DISP), srcvalue:Other:$dummy, i32:Other)
05279   // Emits: (LDL:i64 (imm:i64):$DISP, GPRC:i64:$RB)
05280   // Pattern complexity = 7  cost = 1
05281   if (N1.getOpcode() == ISD::ADD) {
05282     N10 = N1.getOperand(0);
05283     N11 = N1.getOperand(1);
05284     if (N11.getOpcode() == ISD::Constant &&
05285         Predicate_immSExt16(N11.Val)) {
05286       N2 = N.getOperand(2);
05287       N3 = N.getOperand(3);
05288       if (cast<VTSDNode>(N3)->getVT() == MVT::i32) {
05289         uint64_t Tmp0C = (uint64_t)cast<ConstantSDNode>(N11)->getValue();
05290         Tmp0 = CurDAG->getTargetConstant(Tmp0C, MVT::i64);
05291         Select(Tmp1, N10);
05292         Select(Chain, Chain);
05293         ResNode = CurDAG->getTargetNode(Alpha::LDL, MVT::i64, MVT::Other, Tmp0, Tmp1, Chain);
05294         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
05295         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
05296         if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
05297         Result = SDOperand(ResNode, N.ResNo);
05298         return;
05299       }
05300     }
05301   }
05302   if (N1.getOpcode() == AlphaISD::GPRelLo) {
05303     N10 = N1.getOperand(0);
05304 
05305     // Pattern: (sextld:i64 (Alpha_gprello:i64 (tglobaladdr:i64):$DISP, GPRC:i64:$RB), srcvalue:Other:$dummy, i32:Other)
05306     // Emits: (LDLr:i64 (tglobaladdr:i64):$DISP, GPRC:i64:$RB)
05307     // Pattern complexity = 6  cost = 1
05308     if (N10.getOpcode() == ISD::TargetGlobalAddress) {
05309       N11 = N1.getOperand(1);
05310       N2 = N.getOperand(2);
05311       N3 = N.getOperand(3);
05312       if (cast<VTSDNode>(N3)->getVT() == MVT::i32) {
05313         Tmp0 = N10;
05314         Select(Tmp1, N11);
05315         Select(Chain, Chain);
05316         ResNode = CurDAG->getTargetNode(Alpha::LDLr, MVT::i64, MVT::Other, Tmp0, Tmp1, Chain);
05317         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
05318         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
05319         if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
05320         Result = SDOperand(ResNode, N.ResNo);
05321         return;
05322       }
05323     }
05324 
05325     // Pattern: (sextld:i64 (Alpha_gprello:i64 (tconstpool:i64):$DISP, GPRC:i64:$RB), srcvalue:Other:$dummy, i32:Other)
05326     // Emits: (LDLr:i64 (tconstpool:i64):$DISP, GPRC:i64:$RB)
05327     // Pattern complexity = 6  cost = 1
05328     if (N10.getOpcode() == ISD::TargetConstantPool) {
05329       N11 = N1.getOperand(1);
05330       N2 = N.getOperand(2);
05331       N3 = N.getOperand(3);
05332       if (cast<VTSDNode>(N3)->getVT() == MVT::i32) {
05333         Tmp0 = N10;
05334         Select(Tmp1, N11);
05335         Select(Chain, Chain);
05336         ResNode = CurDAG->getTargetNode(Alpha::LDLr, MVT::i64, MVT::Other, Tmp0, Tmp1, Chain);
05337         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
05338         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
05339         if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
05340         Result = SDOperand(ResNode, N.ResNo);
05341         return;
05342       }
05343     }
05344   }
05345 
05346   // Pattern: (sextld:i64 GPRC:i64:$addr, srcvalue:Other:$dummy, i32:Other)
05347   // Emits: (LDL:i64 0:i64, GPRC:i64:$addr)
05348   // Pattern complexity = 2  cost = 1
05349   N2 = N.getOperand(2);
05350   N3 = N.getOperand(3);
05351   if (cast<VTSDNode>(N3)->getVT() == MVT::i32) {
05352     Tmp0 = CurDAG->getTargetConstant(0, MVT::i64);
05353     Select(Tmp1, N1);
05354     Select(Chain, Chain);
05355     ResNode = CurDAG->getTargetNode(Alpha::LDL, MVT::i64, MVT::Other, Tmp0, Tmp1, Chain);
05356     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
05357     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
05358     if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
05359     Result = SDOperand(ResNode, N.ResNo);
05360     return;
05361   }
05362   std::cerr << "Cannot yet select: ";
05363   N.Val->dump(CurDAG);
05364   std::cerr << '\n';
05365   abort();
05366 }
05367 
05368 void Select_shl(SDOperand &Result, SDOperand N) {
05369   SDOperand N0(0, 0);
05370   SDOperand N1(0, 0);
05371   SDOperand Tmp0(0, 0);
05372   SDOperand Tmp1(0, 0);
05373   SDNode *ResNode;
05374   N0 = N.getOperand(0);
05375   N1 = N.getOperand(1);
05376 
05377   // Pattern: (shl:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immUExt8>>:$L)
05378   // Emits: (SLi:i64 GPRC:i64:$RA, (imm:i64):$L)
05379   // Pattern complexity = 5  cost = 1
05380   if (N1.getOpcode() == ISD::Constant &&
05381       Predicate_immUExt8(N1.Val)) {
05382     Select(Tmp0, N0);
05383     uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
05384     Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
05385     if (N.Val->hasOneUse()) {
05386       Result = CurDAG->SelectNodeTo(N.Val, Alpha::SLi, MVT::i64, Tmp0, Tmp1);
05387     } else {
05388       ResNode = CurDAG->getTargetNode(Alpha::SLi, MVT::i64, Tmp0, Tmp1);
05389       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05390       Result = SDOperand(ResNode, 0);
05391     }
05392     return;
05393   }
05394 
05395   // Pattern: (shl:i64 GPRC:i64:$RA, GPRC:i64:$RB)
05396   // Emits: (SL:i64 GPRC:i64:$RA, GPRC:i64:$RB)
05397   // Pattern complexity = 2  cost = 1
05398   Select(Tmp0, N0);
05399   Select(Tmp1, N1);
05400   if (N.Val->hasOneUse()) {
05401     Result = CurDAG->SelectNodeTo(N.Val, Alpha::SL, MVT::i64, Tmp0, Tmp1);
05402   } else {
05403     ResNode = CurDAG->getTargetNode(Alpha::SL, MVT::i64, Tmp0, Tmp1);
05404     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05405     Result = SDOperand(ResNode, 0);
05406   }
05407   return;
05408 }
05409 
05410 void Select_sra(SDOperand &Result, SDOperand N) {
05411   SDOperand N0(0, 0);
05412   SDOperand N1(0, 0);
05413   SDOperand Tmp0(0, 0);
05414   SDOperand Tmp1(0, 0);
05415   SDNode *ResNode;
05416   N0 = N.getOperand(0);
05417   N1 = N.getOperand(1);
05418 
05419   // Pattern: (sra:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immUExt8>>:$L)
05420   // Emits: (SRAi:i64 GPRC:i64:$RA, (imm:i64):$L)
05421   // Pattern complexity = 5  cost = 1
05422   if (N1.getOpcode() == ISD::Constant &&
05423       Predicate_immUExt8(N1.Val)) {
05424     Select(Tmp0, N0);
05425     uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
05426     Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
05427     if (N.Val->hasOneUse()) {
05428       Result = CurDAG->SelectNodeTo(N.Val, Alpha::SRAi, MVT::i64, Tmp0, Tmp1);
05429     } else {
05430       ResNode = CurDAG->getTargetNode(Alpha::SRAi, MVT::i64, Tmp0, Tmp1);
05431       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05432       Result = SDOperand(ResNode, 0);
05433     }
05434     return;
05435   }
05436 
05437   // Pattern: (sra:i64 GPRC:i64:$RA, GPRC:i64:$RB)
05438   // Emits: (SRA:i64 GPRC:i64:$RA, GPRC:i64:$RB)
05439   // Pattern complexity = 2  cost = 1
05440   Select(Tmp0, N0);
05441   Select(Tmp1, N1);
05442   if (N.Val->hasOneUse()) {
05443     Result = CurDAG->SelectNodeTo(N.Val, Alpha::SRA, MVT::i64, Tmp0, Tmp1);
05444   } else {
05445     ResNode = CurDAG->getTargetNode(Alpha::SRA, MVT::i64, Tmp0, Tmp1);
05446     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05447     Result = SDOperand(ResNode, 0);
05448   }
05449   return;
05450 }
05451 
05452 void Select_srl(SDOperand &Result, SDOperand N) {
05453   SDOperand N0(0, 0);
05454   SDOperand N1(0, 0);
05455   SDOperand Tmp0(0, 0);
05456   SDOperand Tmp1(0, 0);
05457   SDNode *ResNode;
05458   N0 = N.getOperand(0);
05459   N1 = N.getOperand(1);
05460 
05461   // Pattern: (srl:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immUExt8>>:$L)
05462   // Emits: (SRLi:i64 GPRC:i64:$RA, (imm:i64):$L)
05463   // Pattern complexity = 5  cost = 1
05464   if (N1.getOpcode() == ISD::Constant &&
05465       Predicate_immUExt8(N1.Val)) {
05466     Select(Tmp0, N0);
05467     uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
05468     Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
05469     if (N.Val->hasOneUse()) {
05470       Result = CurDAG->SelectNodeTo(N.Val, Alpha::SRLi, MVT::i64, Tmp0, Tmp1);
05471     } else {
05472       ResNode = CurDAG->getTargetNode(Alpha::SRLi, MVT::i64, Tmp0, Tmp1);
05473       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05474       Result = SDOperand(ResNode, 0);
05475     }
05476     return;
05477   }
05478 
05479   // Pattern: (srl:i64 GPRC:i64:$RA, GPRC:i64:$RB)
05480   // Emits: (SRL:i64 GPRC:i64:$RA, GPRC:i64:$RB)
05481   // Pattern complexity = 2  cost = 1
05482   Select(Tmp0, N0);
05483   Select(Tmp1, N1);
05484   if (N.Val->hasOneUse()) {
05485     Result = CurDAG->SelectNodeTo(N.Val, Alpha::SRL, MVT::i64, Tmp0, Tmp1);
05486   } else {
05487     ResNode = CurDAG->getTargetNode(Alpha::SRL, MVT::i64, Tmp0, Tmp1);
05488     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05489     Result = SDOperand(ResNode, 0);
05490   }
05491   return;
05492 }
05493 
05494 void Select_store(SDOperand &Result, SDOperand N) {
05495   SDOperand Chain(0, 0);
05496   SDOperand N1(0, 0);
05497   SDOperand N2(0, 0);
05498   SDOperand N20(0, 0);
05499   SDOperand N21(0, 0);
05500   SDOperand Tmp0(0, 0);
05501   SDOperand Tmp1(0, 0);
05502   SDOperand Tmp2(0, 0);
05503   SDNode *ResNode;
05504   Chain = N.getOperand(0);
05505   N1 = N.getOperand(1);
05506   N2 = N.getOperand(2);
05507   if (N2.getOpcode() == ISD::ADD) {
05508     N20 = N2.getOperand(0);
05509     N21 = N2.getOperand(1);
05510     if (N21.getOpcode() == ISD::Constant &&
05511         Predicate_immSExt16(N21.Val)) {
05512 
05513       // Pattern: (store:void GPRC:i64:$RA, (add:i64 GPRC:i64:$RB, (imm:i64)<<P:Predicate_immSExt16>>:$DISP))
05514       // Emits: (STQ:void GPRC:i64:$RA, (imm:i64):$DISP, GPRC:i64:$RB)
05515       // Pattern complexity = 7  cost = 1
05516       if (N1.Val->getValueType(0) == MVT::i64) {
05517         Select(Tmp0, N1);
05518         uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N21)->getValue();
05519         Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
05520         Select(Tmp2, N20);
05521         Select(Chain, Chain);
05522         ResNode = CurDAG->getTargetNode(Alpha::STQ, MVT::Other, Tmp0, Tmp1, Tmp2, Chain);
05523         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
05524         Result = SDOperand(ResNode, N.ResNo);
05525         return;
05526       }
05527 
05528       // Pattern: (store:void F4RC:f32:$RA, (add:i64 GPRC:i64:$RB, (imm:i64)<<P:Predicate_immSExt16>>:$DISP))
05529       // Emits: (STS:void F4RC:f32:$RA, (imm:i64):$DISP, GPRC:i64:$RB)
05530       // Pattern complexity = 7  cost = 1
05531       if (N1.Val->getValueType(0) == MVT::f32) {
05532         Select(Tmp0, N1);
05533         uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N21)->getValue();
05534         Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
05535         Select(Tmp2, N20);
05536         Select(Chain, Chain);
05537         ResNode = CurDAG->getTargetNode(Alpha::STS, MVT::Other, Tmp0, Tmp1, Tmp2, Chain);
05538         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
05539         Result = SDOperand(ResNode, N.ResNo);
05540         return;
05541       }
05542 
05543       // Pattern: (store:void F8RC:f64:$RA, (add:i64 GPRC:i64:$RB, (imm:i64)<<P:Predicate_immSExt16>>:$DISP))
05544       // Emits: (STT:void F8RC:f64:$RA, (imm:i64):$DISP, GPRC:i64:$RB)
05545       // Pattern complexity = 7  cost = 1
05546       if (N1.Val->getValueType(0) == MVT::f64) {
05547         Select(Tmp0, N1);
05548         uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N21)->getValue();
05549         Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
05550         Select(Tmp2, N20);
05551         Select(Chain, Chain);
05552         ResNode = CurDAG->getTargetNode(Alpha::STT, MVT::Other, Tmp0, Tmp1, Tmp2, Chain);
05553         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
05554         Result = SDOperand(ResNode, N.ResNo);
05555         return;
05556       }
05557     }
05558   }
05559   if (N2.getOpcode() == AlphaISD::GPRelLo) {
05560     N20 = N2.getOperand(0);
05561     if (N20.getOpcode() == ISD::TargetGlobalAddress) {
05562       N21 = N2.getOperand(1);
05563 
05564       // Pattern: (store:void GPRC:i64:$RA, (Alpha_gprello:i64 (tglobaladdr:i64):$DISP, GPRC:i64:$RB))
05565       // Emits: (STQr:void GPRC:i64:$RA, (tglobaladdr:i64):$DISP, GPRC:i64:$RB)
05566       // Pattern complexity = 6  cost = 1
05567       if (N1.Val->getValueType(0) == MVT::i64) {
05568         Select(Tmp0, N1);
05569         Tmp1 = N20;
05570         Select(Tmp2, N21);
05571         Select(Chain, Chain);
05572         ResNode = CurDAG->getTargetNode(Alpha::STQr, MVT::Other, Tmp0, Tmp1, Tmp2, Chain);
05573         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
05574         Result = SDOperand(ResNode, N.ResNo);
05575         return;
05576       }
05577 
05578       // Pattern: (store:void F4RC:f32:$RA, (Alpha_gprello:i64 (tglobaladdr:i64):$DISP, GPRC:i64:$RB))
05579       // Emits: (STSr:void F4RC:f32:$RA, (tglobaladdr:i64):$DISP, GPRC:i64:$RB)
05580       // Pattern complexity = 6  cost = 1
05581       if (N1.Val->getValueType(0) == MVT::f32) {
05582         Select(Tmp0, N1);
05583         Tmp1 = N20;
05584         Select(Tmp2, N21);
05585         Select(Chain, Chain);
05586         ResNode = CurDAG->getTargetNode(Alpha::STSr, MVT::Other, Tmp0, Tmp1, Tmp2, Chain);
05587         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
05588         Result = SDOperand(ResNode, N.ResNo);
05589         return;
05590       }
05591 
05592       // Pattern: (store:void F8RC:f64:$RA, (Alpha_gprello:i64 (tglobaladdr:i64):$DISP, GPRC:i64:$RB))
05593       // Emits: (STTr:void F8RC:f64:$RA, (tglobaladdr:i64):$DISP, GPRC:i64:$RB)
05594       // Pattern complexity = 6  cost = 1
05595       if (N1.Val->getValueType(0) == MVT::f64) {
05596         Select(Tmp0, N1);
05597         Tmp1 = N20;
05598         Select(Tmp2, N21);
05599         Select(Chain, Chain);
05600         ResNode = CurDAG->getTargetNode(Alpha::STTr, MVT::Other, Tmp0, Tmp1, Tmp2, Chain);
05601         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
05602         Result = SDOperand(ResNode, N.ResNo);
05603         return;
05604       }
05605     }
05606   }
05607 
05608   // Pattern: (store:void GPRC:i64:$DATA, GPRC:i64:$addr)
05609   // Emits: (STQ:void GPRC:i64:$DATA, 0:i64, GPRC:i64:$addr)
05610   // Pattern complexity = 2  cost = 1
05611   if (N1.Val->getValueType(0) == MVT::i64) {
05612     Select(Tmp0, N1);
05613     Tmp1 = CurDAG->getTargetConstant(0, MVT::i64);
05614     Select(Tmp2, N2);
05615     Select(Chain, Chain);
05616     ResNode = CurDAG->getTargetNode(Alpha::STQ, MVT::Other, Tmp0, Tmp1, Tmp2, Chain);
05617     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
05618     Result = SDOperand(ResNode, N.ResNo);
05619     return;
05620   }
05621 
05622   // Pattern: (store:void F8RC:f64:$DATA, GPRC:i64:$addr)
05623   // Emits: (STT:void F8RC:f64:$DATA, 0:i64, GPRC:i64:$addr)
05624   // Pattern complexity = 2  cost = 1
05625   if (N1.Val->getValueType(0) == MVT::f64) {
05626     Select(Tmp0, N1);
05627     Tmp1 = CurDAG->getTargetConstant(0, MVT::i64);
05628     Select(Tmp2, N2);
05629     Select(Chain, Chain);
05630     ResNode = CurDAG->getTargetNode(Alpha::STT, MVT::Other, Tmp0, Tmp1, Tmp2, Chain);
05631     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
05632     Result = SDOperand(ResNode, N.ResNo);
05633     return;
05634   }
05635 
05636   // Pattern: (store:void F4RC:f32:$DATA, GPRC:i64:$addr)
05637   // Emits: (STS:void F4RC:f32:$DATA, 0:i64, GPRC:i64:$addr)
05638   // Pattern complexity = 2  cost = 1
05639   if (N1.Val->getValueType(0) == MVT::f32) {
05640     Select(Tmp0, N1);
05641     Tmp1 = CurDAG->getTargetConstant(0, MVT::i64);
05642     Select(Tmp2, N2);
05643     Select(Chain, Chain);
05644     ResNode = CurDAG->getTargetNode(Alpha::STS, MVT::Other, Tmp0, Tmp1, Tmp2, Chain);
05645     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
05646     Result = SDOperand(ResNode, N.ResNo);
05647     return;
05648   }
05649   std::cerr << "Cannot yet select: ";
05650   N.Val->dump(CurDAG);
05651   std::cerr << '\n';
05652   abort();
05653 }
05654 
05655 void Select_sub(SDOperand &Result, SDOperand N) {
05656   SDOperand N0(0, 0);
05657   SDOperand N00(0, 0);
05658   SDOperand N01(0, 0);
05659   SDOperand N1(0, 0);
05660   SDOperand Tmp0(0, 0);
05661   SDOperand Tmp1(0, 0);
05662   SDOperand Tmp2(0, 0);
05663   SDNode *ResNode;
05664   N0 = N.getOperand(0);
05665   if (N0.getOpcode() == ISD::SHL) {
05666     N00 = N0.getOperand(0);
05667     N01 = N0.getOperand(1);
05668     if (isa<ConstantSDNode>(N01)) {
05669       int64_t CN0 = cast<ConstantSDNode>(N01)->getSignExtended();
05670       if (CN0 == 2) {
05671         N1 = N.getOperand(1);
05672 
05673         // Pattern: (sub:i64 (shl:i64 GPRC:i64:$RA, 2:i64), (imm:i64)<<P:Predicate_immUExt8>>:$L)
05674         // Emits: (S4SUBQi:i64 GPRC:i64:$RA, (imm:i64):$L)
05675         // Pattern complexity = 10  cost = 1
05676         if (N1.getOpcode() == ISD::Constant &&
05677             Predicate_immUExt8(N1.Val)) {
05678           Select(Tmp1, N00);
05679           uint64_t Tmp2C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
05680           Tmp2 = CurDAG->getTargetConstant(Tmp2C, MVT::i64);
05681           if (N.Val->hasOneUse()) {
05682             Result = CurDAG->SelectNodeTo(N.Val, Alpha::S4SUBQi, MVT::i64, Tmp1, Tmp2);
05683           } else {
05684             ResNode = CurDAG->getTargetNode(Alpha::S4SUBQi, MVT::i64, Tmp1, Tmp2);
05685             SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05686             Result = SDOperand(ResNode, 0);
05687           }
05688           return;
05689         }
05690 
05691         // Pattern: (sub:i64 (shl:i64 GPRC:i64:$RA, 2:i64), GPRC:i64:$RB)
05692         // Emits: (S4SUBQ:i64 GPRC:i64:$RA, GPRC:i64:$RB)
05693         // Pattern complexity = 7  cost = 1
05694         Select(Tmp1, N00);
05695         Select(Tmp2, N1);
05696         if (N.Val->hasOneUse()) {
05697           Result = CurDAG->SelectNodeTo(N.Val, Alpha::S4SUBQ, MVT::i64, Tmp1, Tmp2);
05698         } else {
05699           ResNode = CurDAG->getTargetNode(Alpha::S4SUBQ, MVT::i64, Tmp1, Tmp2);
05700           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05701           Result = SDOperand(ResNode, 0);
05702         }
05703         return;
05704       }
05705 
05706       // Pattern: (sub:i64 (shl:i64 GPRC:i64:$RA, 3:i64), GPRC:i64:$RB)
05707       // Emits: (S8SUBQ:i64 GPRC:i64:$RA, GPRC:i64:$RB)
05708       // Pattern complexity = 7  cost = 1
05709       if (CN0 == 3) {
05710         N1 = N.getOperand(1);
05711         Select(Tmp1, N00);
05712         Select(Tmp2, N1);
05713         if (N.Val->hasOneUse()) {
05714           Result = CurDAG->SelectNodeTo(N.Val, Alpha::S8SUBQ, MVT::i64, Tmp1, Tmp2);
05715         } else {
05716           ResNode = CurDAG->getTargetNode(Alpha::S8SUBQ, MVT::i64, Tmp1, Tmp2);
05717           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05718           Result = SDOperand(ResNode, 0);
05719         }
05720         return;
05721       }
05722     }
05723   }
05724 
05725   // Pattern: (sub:i64 GPRC:i64:$RA, GPRC:i64:$RB)
05726   // Emits: (SUBQ:i64 GPRC:i64:$RA, GPRC:i64:$RB)
05727   // Pattern complexity = 2  cost = 1
05728   N1 = N.getOperand(1);
05729   Select(Tmp0, N0);
05730   Select(Tmp1, N1);
05731   if (N.Val->hasOneUse()) {
05732     Result = CurDAG->SelectNodeTo(N.Val, Alpha::SUBQ, MVT::i64, Tmp0, Tmp1);
05733   } else {
05734     ResNode = CurDAG->getTargetNode(Alpha::SUBQ, MVT::i64, Tmp0, Tmp1);
05735     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05736     Result = SDOperand(ResNode, 0);
05737   }
05738   return;
05739 }
05740 
05741 void Select_truncst(SDOperand &Result, SDOperand N) {
05742   SDOperand Chain(0, 0);
05743   SDOperand N1(0, 0);
05744   SDOperand N2(0, 0);
05745   SDOperand N20(0, 0);
05746   SDOperand N21(0, 0);
05747   SDOperand N3(0, 0);
05748   SDOperand N4(0, 0);
05749   SDOperand Tmp0(0, 0);
05750   SDOperand Tmp1(0, 0);
05751   SDOperand Tmp2(0, 0);
05752   SDNode *ResNode;
05753   Chain = N.getOperand(0);
05754   N1 = N.getOperand(1);
05755   N2 = N.getOperand(2);
05756   if (N2.getOpcode() == ISD::ADD) {
05757     N20 = N2.getOperand(0);
05758     N21 = N2.getOperand(1);
05759     if (N21.getOpcode() == ISD::Constant &&
05760         Predicate_immSExt16(N21.Val)) {
05761       N3 = N.getOperand(3);
05762       N4 = N.getOperand(4);
05763 
05764       // Pattern: (truncst:void GPRC:i64:$RA, (add:i64 GPRC:i64:$RB, (imm:i64)<<P:Predicate_immSExt16>>:$DISP), srcvalue:Other:$dummy, i8:Other)
05765       // Emits: (STB:void GPRC:i64:$RA, (imm:i64):$DISP, GPRC:i64:$RB)
05766       // Pattern complexity = 7  cost = 1
05767       if (cast<VTSDNode>(N4)->getVT() == MVT::i8 &&
05768           N1.Val->getValueType(0) == MVT::i64) {
05769         Select(Tmp0, N1);
05770         uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N21)->getValue();
05771         Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
05772         Select(Tmp2, N20);
05773         Select(Chain, Chain);
05774         ResNode = CurDAG->getTargetNode(Alpha::STB, MVT::Other, Tmp0, Tmp1, Tmp2, Chain);
05775         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
05776         Result = SDOperand(ResNode, N.ResNo);
05777         return;
05778       }
05779 
05780       // Pattern: (truncst:void GPRC:i64:$RA, (add:i64 GPRC:i64:$RB, (imm:i64)<<P:Predicate_immSExt16>>:$DISP), srcvalue:Other:$dummy, i16:Other)
05781       // Emits: (STW:void GPRC:i64:$RA, (imm:i64):$DISP, GPRC:i64:$RB)
05782       // Pattern complexity = 7  cost = 1
05783       if (cast<VTSDNode>(N4)->getVT() == MVT::i16 &&
05784           N1.Val->getValueType(0) == MVT::i64) {
05785         Select(Tmp0, N1);
05786         uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N21)->getValue();
05787         Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
05788         Select(Tmp2, N20);
05789         Select(Chain, Chain);
05790         ResNode = CurDAG->getTargetNode(Alpha::STW, MVT::Other, Tmp0, Tmp1, Tmp2, Chain);
05791         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
05792         Result = SDOperand(ResNode, N.ResNo);
05793         return;
05794       }
05795 
05796       // Pattern: (truncst:void GPRC:i64:$RA, (add:i64 GPRC:i64:$RB, (imm:i64)<<P:Predicate_immSExt16>>:$DISP), srcvalue:Other:$dummy, i32:Other)
05797       // Emits: (STL:void GPRC:i64:$RA, (imm:i64):$DISP, GPRC:i64:$RB)
05798       // Pattern complexity = 7  cost = 1
05799       if (cast<VTSDNode>(N4)->getVT() == MVT::i32 &&
05800           N1.Val->getValueType(0) == MVT::i64) {
05801         Select(Tmp0, N1);
05802         uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N21)->getValue();
05803         Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
05804         Select(Tmp2, N20);
05805         Select(Chain, Chain);
05806         ResNode = CurDAG->getTargetNode(Alpha::STL, MVT::Other, Tmp0, Tmp1, Tmp2, Chain);
05807         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
05808         Result = SDOperand(ResNode, N.ResNo);
05809         return;
05810       }
05811     }
05812   }
05813   if (N2.getOpcode() == AlphaISD::GPRelLo) {
05814     N20 = N2.getOperand(0);
05815     if (N20.getOpcode() == ISD::TargetGlobalAddress) {
05816       N21 = N2.getOperand(1);
05817       N3 = N.getOperand(3);
05818       N4 = N.getOperand(4);
05819 
05820       // Pattern: (truncst:void GPRC:i64:$RA, (Alpha_gprello:i64 (tglobaladdr:i64):$DISP, GPRC:i64:$RB), srcvalue:Other:$dummy, i8:Other)
05821       // Emits: (STBr:void GPRC:i64:$RA, (tglobaladdr:i64):$DISP, GPRC:i64:$RB)
05822       // Pattern complexity = 6  cost = 1
05823       if (cast<VTSDNode>(N4)->getVT() == MVT::i8 &&
05824           N1.Val->getValueType(0) == MVT::i64) {
05825         Select(Tmp0, N1);
05826         Tmp1 = N20;
05827         Select(Tmp2, N21);
05828         Select(Chain, Chain);
05829         ResNode = CurDAG->getTargetNode(Alpha::STBr, MVT::Other, Tmp0, Tmp1, Tmp2, Chain);
05830         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
05831         Result = SDOperand(ResNode, N.ResNo);
05832         return;
05833       }
05834 
05835       // Pattern: (truncst:void GPRC:i64:$RA, (Alpha_gprello:i64 (tglobaladdr:i64):$DISP, GPRC:i64:$RB), srcvalue:Other:$dummy, i16:Other)
05836       // Emits: (STWr:void GPRC:i64:$RA, (tglobaladdr:i64):$DISP, GPRC:i64:$RB)
05837       // Pattern complexity = 6  cost = 1
05838       if (cast<VTSDNode>(N4)->getVT() == MVT::i16 &&
05839           N1.Val->getValueType(0) == MVT::i64) {
05840         Select(Tmp0, N1);
05841         Tmp1 = N20;
05842         Select(Tmp2, N21);
05843         Select(Chain, Chain);
05844         ResNode = CurDAG->getTargetNode(Alpha::STWr, MVT::Other, Tmp0, Tmp1, Tmp2, Chain);
05845         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
05846         Result = SDOperand(ResNode, N.ResNo);
05847         return;
05848       }
05849 
05850       // Pattern: (truncst:void GPRC:i64:$RA, (Alpha_gprello:i64 (tglobaladdr:i64):$DISP, GPRC:i64:$RB), srcvalue:Other:$dummy, i32:Other)
05851       // Emits: (STLr:void GPRC:i64:$RA, (tglobaladdr:i64):$DISP, GPRC:i64:$RB)
05852       // Pattern complexity = 6  cost = 1
05853       if (cast<VTSDNode>(N4)->getVT() == MVT::i32 &&
05854           N1.Val->getValueType(0) == MVT::i64) {
05855         Select(Tmp0, N1);
05856         Tmp1 = N20;
05857         Select(Tmp2, N21);
05858         Select(Chain, Chain);
05859         ResNode = CurDAG->getTargetNode(Alpha::STLr, MVT::Other, Tmp0, Tmp1, Tmp2, Chain);
05860         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
05861         Result = SDOperand(ResNode, N.ResNo);
05862         return;
05863       }
05864     }
05865   }
05866   N3 = N.getOperand(3);
05867   N4 = N.getOperand(4);
05868 
05869   // Pattern: (truncst:void GPRC:i64:$DATA, GPRC:i64:$addr, srcvalue:Other:$dummy, i32:Other)
05870   // Emits: (STL:void GPRC:i64:$DATA, 0:i64, GPRC:i64:$addr)
05871   // Pattern complexity = 2  cost = 1
05872   if (cast<VTSDNode>(N4)->getVT() == MVT::i32 &&
05873       N1.Val->getValueType(0) == MVT::i64) {
05874     Select(Tmp0, N1);
05875     Tmp1 = CurDAG->getTargetConstant(0, MVT::i64);
05876     Select(Tmp2, N2);
05877     Select(Chain, Chain);
05878     ResNode = CurDAG->getTargetNode(Alpha::STL, MVT::Other, Tmp0, Tmp1, Tmp2, Chain);
05879     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
05880     Result = SDOperand(ResNode, N.ResNo);
05881     return;
05882   }
05883 
05884   // Pattern: (truncst:void GPRC:i64:$DATA, GPRC:i64:$addr, srcvalue:Other:$dummy, i16:Other)
05885   // Emits: (STW:void GPRC:i64:$DATA, 0:i64, GPRC:i64:$addr)
05886   // Pattern complexity = 2  cost = 1
05887   if (cast<VTSDNode>(N4)->getVT() == MVT::i16 &&
05888       N1.Val->getValueType(0) == MVT::i64) {
05889     Select(Tmp0, N1);
05890     Tmp1 = CurDAG->getTargetConstant(0, MVT::i64);
05891     Select(Tmp2, N2);
05892     Select(Chain, Chain);
05893     ResNode = CurDAG->getTargetNode(Alpha::STW, MVT::Other, Tmp0, Tmp1, Tmp2, Chain);
05894     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
05895     Result = SDOperand(ResNode, N.ResNo);
05896     return;
05897   }
05898 
05899   // Pattern: (truncst:void GPRC:i64:$DATA, GPRC:i64:$addr, srcvalue:Other:$dummy, i8:Other)
05900   // Emits: (STB:void GPRC:i64:$DATA, 0:i64, GPRC:i64:$addr)
05901   // Pattern complexity = 2  cost = 1
05902   if (cast<VTSDNode>(N4)->getVT() == MVT::i8 &&
05903       N1.Val->getValueType(0) == MVT::i64) {
05904     Select(Tmp0, N1);
05905     Tmp1 = CurDAG->getTargetConstant(0, MVT::i64);
05906     Select(Tmp2, N2);
05907     Select(Chain, Chain);
05908     ResNode = CurDAG->getTargetNode(Alpha::STB, MVT::Other, Tmp0, Tmp1, Tmp2, Chain);
05909     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
05910     Result = SDOperand(ResNode, N.ResNo);
05911     return;
05912   }
05913   std::cerr << "Cannot yet select: ";
05914   N.Val->dump(CurDAG);
05915   std::cerr << '\n';
05916   abort();
05917 }
05918 
05919 void Select_undef(SDOperand &Result, SDOperand N) {
05920   SDNode *ResNode;
05921 
05922   // Pattern: (undef:i64)
05923   // Emits: (IDEF_I:i64)
05924   // Pattern complexity = 2  cost = 1
05925   if (N.Val->getValueType(0) == MVT::i64) {
05926     if (N.Val->hasOneUse()) {
05927       Result = CurDAG->SelectNodeTo(N.Val, Alpha::IDEF_I, MVT::i64);
05928     } else {
05929       ResNode = CurDAG->getTargetNode(Alpha::IDEF_I, MVT::i64);
05930       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05931       Result = SDOperand(ResNode, 0);
05932     }
05933     return;
05934   }
05935 
05936   // Pattern: (undef:f32)
05937   // Emits: (IDEF_F32:f32)
05938   // Pattern complexity = 2  cost = 1
05939   if (N.Val->getValueType(0) == MVT::f32) {
05940     if (N.Val->hasOneUse()) {
05941       Result = CurDAG->SelectNodeTo(N.Val, Alpha::IDEF_F32, MVT::f32);
05942     } else {
05943       ResNode = CurDAG->getTargetNode(Alpha::IDEF_F32, MVT::f32);
05944       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05945       Result = SDOperand(ResNode, 0);
05946     }
05947     return;
05948   }
05949 
05950   // Pattern: (undef:f64)
05951   // Emits: (IDEF_F64:f64)
05952   // Pattern complexity = 2  cost = 1
05953   if (N.Val->getValueType(0) == MVT::f64) {
05954     if (N.Val->hasOneUse()) {
05955       Result = CurDAG->SelectNodeTo(N.Val, Alpha::IDEF_F64, MVT::f64);
05956     } else {
05957       ResNode = CurDAG->getTargetNode(Alpha::IDEF_F64, MVT::f64);
05958       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05959       Result = SDOperand(ResNode, 0);
05960     }
05961     return;
05962   }
05963   std::cerr << "Cannot yet select: ";
05964   N.Val->dump(CurDAG);
05965   std::cerr << '\n';
05966   abort();
05967 }
05968 
05969 void Select_xor(SDOperand &Result, SDOperand N) {
05970   SDOperand N0(0, 0);
05971   SDOperand N00(0, 0);
05972   SDOperand N01(0, 0);
05973   SDOperand N1(0, 0);
05974   SDOperand N10(0, 0);
05975   SDOperand N11(0, 0);
05976   SDOperand Tmp0(0, 0);
05977   SDOperand Tmp1(0, 0);
05978   SDOperand Tmp2(0, 0);
05979   SDNode *ResNode;
05980   N0 = N.getOperand(0);
05981 
05982   // Pattern: (xor:i64 GPRC:i64:$RA, (xor:i64 GPRC:i64:$RB, (imm:i64)<<P:Predicate_immAllOnes>>))
05983   // Emits: (EQV:i64 GPRC:i64:$RA, GPRC:i64:$RB)
05984   // Pattern complexity = 7  cost = 1
05985   {
05986     N1 = N.getOperand(1);
05987     if (N1.getOpcode() == ISD::XOR) {
05988       N10 = N1.getOperand(0);
05989       N11 = N1.getOperand(1);
05990       if (N11.getOpcode() == ISD::Constant &&
05991           Predicate_immAllOnes(N11.Val)) {
05992         Select(Tmp0, N0);
05993         Select(Tmp1, N10);
05994         if (N.Val->hasOneUse()) {
05995           Result = CurDAG->SelectNodeTo(N.Val, Alpha::EQV, MVT::i64, Tmp0, Tmp1);
05996         } else {
05997           ResNode = CurDAG->getTargetNode(Alpha::EQV, MVT::i64, Tmp0, Tmp1);
05998           SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
05999           Result = SDOperand(ResNode, 0);
06000         }
06001         return;
06002       }
06003     }
06004   }
06005 
06006   // Pattern: (xor:i64 (xor:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immAllOnes>>), GPRC:i64:$RB)
06007   // Emits: (EQV:i64 GPRC:i64:$RA, GPRC:i64:$RB)
06008   // Pattern complexity = 7  cost = 1
06009   if (N0.getOpcode() == ISD::XOR) {
06010     N00 = N0.getOperand(0);
06011     N01 = N0.getOperand(1);
06012     if (N01.getOpcode() == ISD::Constant &&
06013         Predicate_immAllOnes(N01.Val)) {
06014       N1 = N.getOperand(1);
06015       Select(Tmp0, N00);
06016       Select(Tmp1, N1);
06017       if (N.Val->hasOneUse()) {
06018         Result = CurDAG->SelectNodeTo(N.Val, Alpha::EQV, MVT::i64, Tmp0, Tmp1);
06019       } else {
06020         ResNode = CurDAG->getTargetNode(Alpha::EQV, MVT::i64, Tmp0, Tmp1);
06021         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
06022         Result = SDOperand(ResNode, 0);
06023       }
06024       return;
06025     }
06026   }
06027   N1 = N.getOperand(1);
06028   if (N1.getOpcode() == ISD::Constant) {
06029 
06030     // Pattern: (xor:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immUExt8inv>><<X:invX>>:$L)
06031     // Emits: (EQVi:i64 GPRC:i64:$RA, (invX:i64 (imm:i64):$L))
06032     // Pattern complexity = 5  cost = 1
06033     if (Predicate_immUExt8inv(N1.Val)) {
06034       Select(Tmp0, N0);
06035       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
06036       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
06037       Tmp2 = Transform_invX(Tmp1.Val);
06038       if (N.Val->hasOneUse()) {
06039         Result = CurDAG->SelectNodeTo(N.Val, Alpha::EQVi, MVT::i64, Tmp0, Tmp2);
06040       } else {
06041         ResNode = CurDAG->getTargetNode(Alpha::EQVi, MVT::i64, Tmp0, Tmp2);
06042         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
06043         Result = SDOperand(ResNode, 0);
06044       }
06045       return;
06046     }
06047 
06048     // Pattern: (xor:i64 GPRC:i64:$RA, (imm:i64)<<P:Predicate_immUExt8>>:$L)
06049     // Emits: (XORi:i64 GPRC:i64:$RA, (imm:i64):$L)
06050     // Pattern complexity = 5  cost = 1
06051     if (Predicate_immUExt8(N1.Val)) {
06052       Select(Tmp0, N0);
06053       uint64_t Tmp1C = (uint64_t)cast<ConstantSDNode>(N1)->getValue();
06054       Tmp1 = CurDAG->getTargetConstant(Tmp1C, MVT::i64);
06055       if (N.Val->hasOneUse()) {
06056         Result = CurDAG->SelectNodeTo(N.Val, Alpha::XORi, MVT::i64, Tmp0, Tmp1);
06057       } else {
06058         ResNode = CurDAG->getTargetNode(Alpha::XORi, MVT::i64, Tmp0, Tmp1);
06059         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
06060         Result = SDOperand(ResNode, 0);
06061       }
06062       return;
06063     }
06064   }
06065 
06066   // Pattern: (xor:i64 GPRC:i64:$RA, GPRC:i64:$RB)
06067   // Emits: (XOR:i64 GPRC:i64:$RA, GPRC:i64:$RB)
06068   // Pattern complexity = 2  cost = 1
06069   Select(Tmp0, N0);
06070   Select(Tmp1, N1);
06071   if (N.Val->hasOneUse()) {
06072     Result = CurDAG->SelectNodeTo(N.Val, Alpha::XOR, MVT::i64, Tmp0, Tmp1);
06073   } else {
06074     ResNode = CurDAG->getTargetNode(Alpha::XOR, MVT::i64, Tmp0, Tmp1);
06075     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0);
06076     Result = SDOperand(ResNode, 0);
06077   }
06078   return;
06079 }
06080 
06081 void Select_zextld(SDOperand &Result, SDOperand N) {
06082   if (N.ResNo == 1 && N.getValue(0).hasOneUse()) {
06083     SDOperand Dummy = CurDAG->getNode(ISD::HANDLENODE, MVT::Other, N);
06084     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, Dummy.Val, 0);
06085     SelectionDAG::InsertISelMapEntry(HandleMap, N.Val, 1, Dummy.Val, 0);
06086     Result = Dummy;
06087     return;
06088   }
06089   SDOperand Chain(0, 0);
06090   SDOperand N1(0, 0);
06091   SDOperand N10(0, 0);
06092   SDOperand N11(0, 0);
06093   SDOperand N2(0, 0);
06094   SDOperand N3(0, 0);
06095   SDOperand Tmp0(0, 0);
06096   SDOperand Tmp1(0, 0);
06097   SDNode *ResNode;
06098   Chain = N.getOperand(0);
06099   N1 = N.getOperand(1);
06100   if (N1.getOpcode() == ISD::ADD) {
06101     N10 = N1.getOperand(0);
06102     N11 = N1.getOperand(1);
06103     if (N11.getOpcode() == ISD::Constant &&
06104         Predicate_immSExt16(N11.Val)) {
06105       N2 = N.getOperand(2);
06106       N3 = N.getOperand(3);
06107 
06108       // Pattern: (zextld:i64 (add:i64 GPRC:i64:$RB, (imm:i64)<<P:Predicate_immSExt16>>:$DISP), srcvalue:Other:$dummy, i8:Other)
06109       // Emits: (LDBU:i64 (imm:i64):$DISP, GPRC:i64:$RB)
06110       // Pattern complexity = 7  cost = 1
06111       if (cast<VTSDNode>(N3)->getVT() == MVT::i8) {
06112         uint64_t Tmp0C = (uint64_t)cast<ConstantSDNode>(N11)->getValue();
06113         Tmp0 = CurDAG->getTargetConstant(Tmp0C, MVT::i64);
06114         Select(Tmp1, N10);
06115         Select(Chain, Chain);
06116         ResNode = CurDAG->getTargetNode(Alpha::LDBU, MVT::i64, MVT::Other, Tmp0, Tmp1, Chain);
06117         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
06118         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
06119         if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
06120         Result = SDOperand(ResNode, N.ResNo);
06121         return;
06122       }
06123 
06124       // Pattern: (zextld:i64 (add:i64 GPRC:i64:$RB, (imm:i64)<<P:Predicate_immSExt16>>:$DISP), srcvalue:Other:$dummy, i16:Other)
06125       // Emits: (LDWU:i64 (imm:i64):$DISP, GPRC:i64:$RB)
06126       // Pattern complexity = 7  cost = 1
06127       if (cast<VTSDNode>(N3)->getVT() == MVT::i16) {
06128         uint64_t Tmp0C = (uint64_t)cast<ConstantSDNode>(N11)->getValue();
06129         Tmp0 = CurDAG->getTargetConstant(Tmp0C, MVT::i64);
06130         Select(Tmp1, N10);
06131         Select(Chain, Chain);
06132         ResNode = CurDAG->getTargetNode(Alpha::LDWU, MVT::i64, MVT::Other, Tmp0, Tmp1, Chain);
06133         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
06134         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
06135         if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
06136         Result = SDOperand(ResNode, N.ResNo);
06137         return;
06138       }
06139     }
06140   }
06141   if (N1.getOpcode() == AlphaISD::GPRelLo) {
06142     N10 = N1.getOperand(0);
06143     if (N10.getOpcode() == ISD::TargetGlobalAddress) {
06144       N11 = N1.getOperand(1);
06145       N2 = N.getOperand(2);
06146       N3 = N.getOperand(3);
06147 
06148       // Pattern: (zextld:i64 (Alpha_gprello:i64 (tglobaladdr:i64):$DISP, GPRC:i64:$RB), srcvalue:Other:$dummy, i8:Other)
06149       // Emits: (LDBUr:i64 (tglobaladdr:i64):$DISP, GPRC:i64:$RB)
06150       // Pattern complexity = 6  cost = 1
06151       if (cast<VTSDNode>(N3)->getVT() == MVT::i8) {
06152         Tmp0 = N10;
06153         Select(Tmp1, N11);
06154         Select(Chain, Chain);
06155         ResNode = CurDAG->getTargetNode(Alpha::LDBUr, MVT::i64, MVT::Other, Tmp0, Tmp1, Chain);
06156         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
06157         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
06158         if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
06159         Result = SDOperand(ResNode, N.ResNo);
06160         return;
06161       }
06162 
06163       // Pattern: (zextld:i64 (Alpha_gprello:i64 (tglobaladdr:i64):$DISP, GPRC:i64:$RB), srcvalue:Other:$dummy, i16:Other)
06164       // Emits: (LDWUr:i64 (tglobaladdr:i64):$DISP, GPRC:i64:$RB)
06165       // Pattern complexity = 6  cost = 1
06166       if (cast<VTSDNode>(N3)->getVT() == MVT::i16) {
06167         Tmp0 = N10;
06168         Select(Tmp1, N11);
06169         Select(Chain, Chain);
06170         ResNode = CurDAG->getTargetNode(Alpha::LDWUr, MVT::i64, MVT::Other, Tmp0, Tmp1, Chain);
06171         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
06172         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
06173         if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
06174         Result = SDOperand(ResNode, N.ResNo);
06175         return;
06176       }
06177     }
06178     if (N10.getOpcode() == ISD::TargetConstantPool) {
06179       N11 = N1.getOperand(1);
06180       N2 = N.getOperand(2);
06181       N3 = N.getOperand(3);
06182 
06183       // Pattern: (zextld:i64 (Alpha_gprello:i64 (tconstpool:i64):$DISP, GPRC:i64:$RB), srcvalue:Other:$dummy, i8:Other)
06184       // Emits: (LDBUr:i64 (tconstpool:i64):$DISP, GPRC:i64:$RB)
06185       // Pattern complexity = 6  cost = 1
06186       if (cast<VTSDNode>(N3)->getVT() == MVT::i8) {
06187         Tmp0 = N10;
06188         Select(Tmp1, N11);
06189         Select(Chain, Chain);
06190         ResNode = CurDAG->getTargetNode(Alpha::LDBUr, MVT::i64, MVT::Other, Tmp0, Tmp1, Chain);
06191         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
06192         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
06193         if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
06194         Result = SDOperand(ResNode, N.ResNo);
06195         return;
06196       }
06197 
06198       // Pattern: (zextld:i64 (Alpha_gprello:i64 (tconstpool:i64):$DISP, GPRC:i64:$RB), srcvalue:Other:$dummy, i16:Other)
06199       // Emits: (LDWUr:i64 (tconstpool:i64):$DISP, GPRC:i64:$RB)
06200       // Pattern complexity = 6  cost = 1
06201       if (cast<VTSDNode>(N3)->getVT() == MVT::i16) {
06202         Tmp0 = N10;
06203         Select(Tmp1, N11);
06204         Select(Chain, Chain);
06205         ResNode = CurDAG->getTargetNode(Alpha::LDWUr, MVT::i64, MVT::Other, Tmp0, Tmp1, Chain);
06206         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
06207         SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
06208         if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
06209         Result = SDOperand(ResNode, N.ResNo);
06210         return;
06211       }
06212     }
06213   }
06214   N2 = N.getOperand(2);
06215   N3 = N.getOperand(3);
06216 
06217   // Pattern: (zextld:i64 GPRC:i64:$addr, srcvalue:Other:$dummy, i16:Other)
06218   // Emits: (LDWU:i64 0:i64, GPRC:i64:$addr)
06219   // Pattern complexity = 2  cost = 1
06220   if (cast<VTSDNode>(N3)->getVT() == MVT::i16) {
06221     Tmp0 = CurDAG->getTargetConstant(0, MVT::i64);
06222     Select(Tmp1, N1);
06223     Select(Chain, Chain);
06224     ResNode = CurDAG->getTargetNode(Alpha::LDWU, MVT::i64, MVT::Other, Tmp0, Tmp1, Chain);
06225     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
06226     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
06227     if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
06228     Result = SDOperand(ResNode, N.ResNo);
06229     return;
06230   }
06231 
06232   // Pattern: (zextld:i64 GPRC:i64:$addr, srcvalue:Other:$dummy, i8:Other)
06233   // Emits: (LDBU:i64 0:i64, GPRC:i64:$addr)
06234   // Pattern complexity = 2  cost = 1
06235   if (cast<VTSDNode>(N3)->getVT() == MVT::i8) {
06236     Tmp0 = CurDAG->getTargetConstant(0, MVT::i64);
06237     Select(Tmp1, N1);
06238     Select(Chain, Chain);
06239     ResNode = CurDAG->getTargetNode(Alpha::LDBU, MVT::i64, MVT::Other, Tmp0, Tmp1, Chain);
06240     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0);
06241     SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, ResNode, 1);
06242     if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, ResNode, 1);
06243     Result = SDOperand(ResNode, N.ResNo);
06244     return;
06245   }
06246   std::cerr << "Cannot yet select: ";
06247   N.Val->dump(CurDAG);
06248   std::cerr << '\n';
06249   abort();
06250 }
06251 
06252 void Select_INLINEASM(SDOperand& Result, SDOperand N) {
06253   std::vector<SDOperand> Ops(N.Val->op_begin(), N.Val->op_end());
06254   Select(Ops[0], N.getOperand(0)); // Select the chain.
06255 
06256   // Select the flag operand.
06257   if (Ops.back().getValueType() == MVT::Flag)
06258     Select(Ops.back(), Ops.back());
06259   SelectInlineAsmMemoryOperands(Ops, *CurDAG);
06260   std::vector<MVT::ValueType> VTs;
06261   VTs.push_back(MVT::Other);
06262   VTs.push_back(MVT::Flag);
06263   SDOperand New = CurDAG->getNode(ISD::INLINEASM, VTs, Ops);
06264   SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, New.Val, 0);
06265   SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, New.Val, 1);
06266   Result = New.getValue(N.ResNo);
06267   return;
06268 }
06269 
06270 // The main instruction selector code.
06271 void SelectCode(SDOperand &Result, SDOperand N) {
06272   if (N.getOpcode() >= ISD::BUILTIN_OP_END &&
06273       N.getOpcode() < (ISD::BUILTIN_OP_END+Alpha::INSTRUCTION_LIST_END)) {
06274     Result = N;
06275     return;   // Already selected.
06276   }
06277 
06278   std::map<SDOperand, SDOperand>::iterator CGMI = CodeGenMap.find(N);
06279   if (CGMI != CodeGenMap.end()) {
06280     Result = CGMI->second;
06281     return;
06282   }
06283 
06284   switch (N.getOpcode()) {
06285   default: break;
06286   case ISD::EntryToken:       // These leaves remain the same.
06287   case ISD::BasicBlock:
06288   case ISD::Register:
06289   case ISD::HANDLENODE:
06290   case ISD::TargetConstant:
06291   case ISD::TargetConstantPool:
06292   case ISD::TargetFrameIndex:
06293   case ISD::TargetGlobalAddress: {
06294     Result = N;
06295     return;
06296   }
06297   case ISD::AssertSext:
06298   case ISD::AssertZext: {
06299     SDOperand Tmp0;
06300     Select(Tmp0, N.getOperand(0));
06301     if (!N.Val->hasOneUse())
06302       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, Tmp0.Val, Tmp0.ResNo);
06303     Result = Tmp0;
06304     return;
06305   }
06306   case ISD::TokenFactor:
06307     if (N.getNumOperands() == 2) {
06308       SDOperand Op0, Op1;
06309       Select(Op0, N.getOperand(0));
06310       Select(Op1, N.getOperand(1));
06311       Result = 
06312           CurDAG->getNode(ISD::TokenFactor, MVT::Other, Op0, Op1);
06313       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, Result.Val, Result.ResNo);
06314     } else {
06315       std::vector<SDOperand> Ops;
06316       for (unsigned i = 0, e = N.getNumOperands(); i != e; ++i) {
06317         SDOperand Val;
06318         Select(Val, N.getOperand(i));
06319         Ops.push_back(Val);
06320       }
06321       Result = 
06322           CurDAG->getNode(ISD::TokenFactor, MVT::Other, Ops);
06323       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, Result.Val, Result.ResNo);
06324     }
06325     return;
06326   case ISD::CopyFromReg: {
06327     SDOperand Chain;
06328     Select(Chain, N.getOperand(0));
06329     unsigned Reg = cast<RegisterSDNode>(N.getOperand(1))->getReg();
06330     MVT::ValueType VT = N.Val->getValueType(0);
06331     if (N.Val->getNumValues() == 2) {
06332       if (Chain == N.getOperand(0)) {
06333         Result = N; // No change
06334         return;
06335       }
06336       SDOperand New = CurDAG->getCopyFromReg(Chain, Reg, VT);
06337       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, New.Val, 0);
06338       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, New.Val, 1);
06339       Result = New.getValue(N.ResNo);
06340       return;
06341     } else {
06342       SDOperand Flag;
06343       if (N.getNumOperands() == 3) Select(Flag, N.getOperand(2));
06344       if (Chain == N.getOperand(0) &&
06345           (N.getNumOperands() == 2 || Flag == N.getOperand(2))) {
06346         Result = N; // No change
06347         return;
06348       }
06349       SDOperand New = CurDAG->getCopyFromReg(Chain, Reg, VT, Flag);
06350       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, New.Val, 0);
06351       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, New.Val, 1);
06352       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 2, New.Val, 2);
06353       Result = New.getValue(N.ResNo);
06354       return;
06355     }
06356   }
06357   case ISD::CopyToReg: {
06358     SDOperand Chain;
06359     Select(Chain, N.getOperand(0));
06360     unsigned Reg = cast<RegisterSDNode>(N.getOperand(1))->getReg();
06361     SDOperand Val;
06362     Select(Val, N.getOperand(2));
06363     Result = N;
06364     if (N.Val->getNumValues() == 1) {
06365       if (Chain != N.getOperand(0) || Val != N.getOperand(2))
06366         Result = CurDAG->getCopyToReg(Chain, Reg, Val);
06367       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, Result.Val, 0);
06368     } else {
06369       SDOperand Flag(0, 0);
06370       if (N.getNumOperands() == 4) Select(Flag, N.getOperand(3));
06371       if (Chain != N.getOperand(0) || Val != N.getOperand(2) ||
06372           (N.getNumOperands() == 4 && Flag != N.getOperand(3)))
06373         Result = CurDAG->getCopyToReg(Chain, Reg, Val, Flag);
06374       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, Result.Val, 0);
06375       SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, Result.Val, 1);
06376       Result = Result.getValue(N.ResNo);
06377     }
06378     return;
06379   }
06380   case ISD::INLINEASM:  Select_INLINEASM(Result, N); return;
06381   case AlphaISD::CVTQS_:         Select_Alpha_cvtqs(Result, N); return;
06382   case AlphaISD::CVTQT_:         Select_Alpha_cvtqt(Result, N); return;
06383   case AlphaISD::CVTTQ_:         Select_Alpha_cvttq(Result, N); return;
06384   case AlphaISD::FTOIT_:         Select_Alpha_ftoit(Result, N); return;
06385   case AlphaISD::GPRelHi:        Select_Alpha_gprelhi(Result, N); return;
06386   case AlphaISD::GPRelLo:        Select_Alpha_gprello(Result, N); return;
06387   case AlphaISD::ITOFT_:         Select_Alpha_itoft(Result, N); return;
06388   case AlphaISD::RelLit:         Select_Alpha_rellit(Result, N); return;
06389   case ISD::ADD:                 Select_add(Result, N); return;
06390   case ISD::AND:                 Select_and(Result, N); return;
06391   case ISD::BR:                  Select_br(Result, N); return;
06392   case ISD::BRCOND:              Select_brcond(Result, N); return;
06393   case ISD::CALLSEQ_END:         Select_callseq_end(Result, N); return;
06394   case ISD::CALLSEQ_START:       Select_callseq_start(Result, N); return;
06395   case ISD::CTLZ:                Select_ctlz(Result, N); return;
06396   case ISD::CTPOP:               Select_ctpop(Result, N); return;
06397   case ISD::CTTZ:                Select_cttz(Result, N); return;
06398   case ISD::EXTLOAD:             Select_extld(Result, N); return;
06399   case ISD::FABS:                Select_fabs(Result, N); return;
06400   case ISD::FADD:                Select_fadd(Result, N); return;
06401   case ISD::FCOPYSIGN:           Select_fcopysign(Result, N); return;
06402   case ISD::FDIV:                Select_fdiv(Result, N); return;
06403   case ISD::FP_EXTEND:           Select_fextend(Result, N); return;
06404   case ISD::FMUL:                Select_fmul(Result, N); return;
06405   case ISD::FNEG:                Select_fneg(Result, N); return;
06406   case ISD::FP_ROUND:            Select_fround(Result, N); return;
06407   case ISD::FSQRT:               Select_fsqrt(Result, N); return;
06408   case ISD::FSUB:                Select_fsub(Result, N); return;
06409   case ISD::Constant:            Select_imm(Result, N); return;
06410   case ISD::LOAD:                Select_load(Result, N); return;
06411   case ISD::MUL:                 Select_mul(Result, N); return;
06412   case ISD::MULHS:               Select_mulhs(Result, N); return;
06413   case ISD::MULHU:               Select_mulhu(Result, N); return;
06414   case ISD::OR:                  Select_or(Result, N); return;
06415   case ISD::SELECT:              Select_select(Result, N); return;
06416   case ISD::SETCC:               Select_setcc(Result, N); return;
06417   case ISD::SIGN_EXTEND_INREG:   Select_sext_inreg(Result, N); return;
06418   case ISD::SEXTLOAD:            Select_sextld(Result, N); return;
06419   case ISD::SHL:                 Select_shl(Result, N); return;
06420   case ISD::SRA:                 Select_sra(Result, N); return;
06421   case ISD::SRL:                 Select_srl(Result, N); return;
06422   case ISD::STORE:               Select_store(Result, N); return;
06423   case ISD::SUB:                 Select_sub(Result, N); return;
06424   case ISD::TRUNCSTORE:          Select_truncst(Result, N); return;
06425   case ISD::UNDEF:               Select_undef(Result, N); return;
06426   case ISD::XOR:                 Select_xor(Result, N); return;
06427   case ISD::ZEXTLOAD:            Select_zextld(Result, N); return;
06428   } // end of big switch.
06429 
06430   std::cerr << "Cannot yet select: ";
06431   if (N.getOpcode() != ISD::INTRINSIC_W_CHAIN &&
06432       N.getOpcode() != ISD::INTRINSIC_WO_CHAIN &&
06433       N.getOpcode() != ISD::INTRINSIC_VOID) {
06434     N.Val->dump(CurDAG);
06435   } else {
06436     unsigned iid = cast<ConstantSDNode>(N.getOperand(N.getOperand(0).getValueType() == MVT::Other))->getValue();
06437     std::cerr << "intrinsic %"<< Intrinsic::getName((Intrinsic::ID)iid);
06438   }
06439   std::cerr << '\n';
06440   abort();
06441 }