[llvm] [PowerPC] Use setbc for values from vector compare conditions (PR #114858)
Amy Kwan via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 7 13:55:32 PST 2024
================
@@ -11264,31 +11268,55 @@ SDValue PPCTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
EVT VTs[] = { Op.getOperand(2).getValueType(), MVT::Glue };
SDValue CompNode = DAG.getNode(PPCISD::VCMP_rec, dl, VTs, Ops);
- // Now that we have the comparison, emit a copy from the CR to a GPR.
- // This is flagged to the above dot comparison.
- SDValue Flags = DAG.getNode(PPCISD::MFOCRF, dl, MVT::i32,
- DAG.getRegister(PPC::CR6, MVT::i32),
- CompNode.getValue(1));
-
// Unpack the result based on how the target uses it.
- unsigned BitNo; // Bit # of CR6.
- bool InvertBit; // Invert result?
+ unsigned BitNo; // Bit # of CR6.
+ bool InvertBit; // Invert result?
+ unsigned Bitx;
+ unsigned SetOp;
switch (Op.getConstantOperandVal(1)) {
- default: // Can't happen, don't crash on invalid number though.
- case 0: // Return the value of the EQ bit of CR6.
- BitNo = 0; InvertBit = false;
+ default: // Can't happen, don't crash on invalid number though.
+ case 0: // Return the value of the EQ bit of CR6.
+ BitNo = 0;
+ InvertBit = false;
+ Bitx = PPC::sub_eq;
+ SetOp = PPCISD::SETBC;
break;
- case 1: // Return the inverted value of the EQ bit of CR6.
- BitNo = 0; InvertBit = true;
+ case 1: // Return the inverted value of the EQ bit of CR6.
+ BitNo = 0;
+ InvertBit = true;
+ Bitx = PPC::sub_eq;
+ SetOp = PPCISD::SETBCR;
break;
- case 2: // Return the value of the LT bit of CR6.
- BitNo = 2; InvertBit = false;
+ case 2: // Return the value of the LT bit of CR6.
+ BitNo = 2;
+ InvertBit = false;
+ Bitx = PPC::sub_lt;
+ SetOp = PPCISD::SETBC;
break;
- case 3: // Return the inverted value of the LT bit of CR6.
- BitNo = 2; InvertBit = true;
+ case 3: // Return the inverted value of the LT bit of CR6.
+ BitNo = 2;
+ InvertBit = true;
+ Bitx = PPC::sub_lt;
+ SetOp = PPCISD::SETBCR;
break;
}
+ if (Subtarget.isISA3_1()) {
+ SDValue SubRegIdx = DAG.getTargetConstant(Bitx, dl, MVT::i32);
+ SDValue CR6Reg = DAG.getRegister(PPC::CR6, MVT::i32);
+ SDValue CRBit =
+ SDValue(DAG.getMachineNode(TargetOpcode::EXTRACT_SUBREG, dl, MVT::i1,
+ CR6Reg, SubRegIdx, CompNode.getValue(1)),
----------------
amy-kwan wrote:
nit: Maybe pull out `CompNode.getValue(1)` since its used in both P10 and pre-P10 case.
https://github.com/llvm/llvm-project/pull/114858
More information about the llvm-commits
mailing list