@@ -1842,6 +1842,10 @@ const char *PPCTargetLowering::getTargetNodeName(unsigned Opcode) const {
18421842 case PPCISD::LXVRZX: return "PPCISD::LXVRZX";
18431843 case PPCISD::STORE_COND:
18441844 return "PPCISD::STORE_COND";
1845+ case PPCISD::SETBC:
1846+ return "PPCISD::SETBC";
1847+ case PPCISD::SETBCR:
1848+ return "PPCISD::SETBCR";
18451849 }
18461850 return nullptr;
18471851}
@@ -11256,31 +11260,55 @@ SDValue PPCTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
1125611260 EVT VTs[] = { Op.getOperand(2).getValueType(), MVT::Glue };
1125711261 SDValue CompNode = DAG.getNode(PPCISD::VCMP_rec, dl, VTs, Ops);
1125811262
11259- // Now that we have the comparison, emit a copy from the CR to a GPR.
11260- // This is flagged to the above dot comparison.
11261- SDValue Flags = DAG.getNode(PPCISD::MFOCRF, dl, MVT::i32,
11262- DAG.getRegister(PPC::CR6, MVT::i32),
11263- CompNode.getValue(1));
11264-
1126511263 // Unpack the result based on how the target uses it.
11266- unsigned BitNo; // Bit # of CR6.
11267- bool InvertBit; // Invert result?
11264+ unsigned BitNo; // Bit # of CR6.
11265+ bool InvertBit; // Invert result?
11266+ unsigned Bitx;
11267+ unsigned SetOp;
1126811268 switch (Op.getConstantOperandVal(1)) {
11269- default: // Can't happen, don't crash on invalid number though.
11270- case 0: // Return the value of the EQ bit of CR6.
11271- BitNo = 0; InvertBit = false;
11269+ default: // Can't happen, don't crash on invalid number though.
11270+ case 0: // Return the value of the EQ bit of CR6.
11271+ BitNo = 0;
11272+ InvertBit = false;
11273+ Bitx = PPC::sub_eq;
11274+ SetOp = PPCISD::SETBC;
1127211275 break;
11273- case 1: // Return the inverted value of the EQ bit of CR6.
11274- BitNo = 0; InvertBit = true;
11276+ case 1: // Return the inverted value of the EQ bit of CR6.
11277+ BitNo = 0;
11278+ InvertBit = true;
11279+ Bitx = PPC::sub_eq;
11280+ SetOp = PPCISD::SETBCR;
1127511281 break;
11276- case 2: // Return the value of the LT bit of CR6.
11277- BitNo = 2; InvertBit = false;
11282+ case 2: // Return the value of the LT bit of CR6.
11283+ BitNo = 2;
11284+ InvertBit = false;
11285+ Bitx = PPC::sub_lt;
11286+ SetOp = PPCISD::SETBC;
1127811287 break;
11279- case 3: // Return the inverted value of the LT bit of CR6.
11280- BitNo = 2; InvertBit = true;
11288+ case 3: // Return the inverted value of the LT bit of CR6.
11289+ BitNo = 2;
11290+ InvertBit = true;
11291+ Bitx = PPC::sub_lt;
11292+ SetOp = PPCISD::SETBCR;
1128111293 break;
1128211294 }
1128311295
11296+ SDValue GlueOp = CompNode.getValue(1);
11297+ if (Subtarget.isISA3_1()) {
11298+ SDValue SubRegIdx = DAG.getTargetConstant(Bitx, dl, MVT::i32);
11299+ SDValue CR6Reg = DAG.getRegister(PPC::CR6, MVT::i32);
11300+ SDValue CRBit =
11301+ SDValue(DAG.getMachineNode(TargetOpcode::EXTRACT_SUBREG, dl, MVT::i1,
11302+ CR6Reg, SubRegIdx, GlueOp),
11303+ 0);
11304+ return DAG.getNode(SetOp, dl, MVT::i32, CRBit);
11305+ }
11306+
11307+ // Now that we have the comparison, emit a copy from the CR to a GPR.
11308+ // This is flagged to the above dot comparison.
11309+ SDValue Flags = DAG.getNode(PPCISD::MFOCRF, dl, MVT::i32,
11310+ DAG.getRegister(PPC::CR6, MVT::i32), GlueOp);
11311+
1128411312 // Shift the bit into the low position.
1128511313 Flags = DAG.getNode(ISD::SRL, dl, MVT::i32, Flags,
1128611314 DAG.getConstant(8 - (3 - BitNo), dl, MVT::i32));
0 commit comments