-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[PowePC] using MTVSRBMI instruction instead of constant pool in power10+ #144084
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9580,6 +9580,37 @@ static bool isValidSplatLoad(const PPCSubtarget &Subtarget, const SDValue &Op, | |
| return false; | ||
| } | ||
|
|
||
| bool isValidMtVsrbmi(APInt &BMI, BuildVectorSDNode &BVN) { | ||
| unsigned int NumOps = BVN.getNumOperands(); | ||
| assert(NumOps > 0 && "isConstantSplat has 0-size build vector"); | ||
|
||
|
|
||
| BMI.clearAllBits(); | ||
| EVT VT = BVN.getValueType(0); | ||
| APInt ConstValue(VT.getSizeInBits(), 0); | ||
|
|
||
| unsigned EltWidth = VT.getScalarSizeInBits(); | ||
|
|
||
| for (unsigned j = 0; j < NumOps; ++j) { | ||
|
||
| SDValue OpVal = BVN.getOperand(j); | ||
| unsigned BitPos = j * EltWidth; | ||
| auto *CN = dyn_cast<ConstantSDNode>(OpVal); | ||
|
|
||
| if (!CN) | ||
| return false; | ||
|
|
||
| ConstValue.insertBits(CN->getAPIntValue().zextOrTrunc(EltWidth), BitPos); | ||
| } | ||
|
|
||
| for (unsigned J = 0; J < 16; J++) { | ||
|
||
| APInt ExtractValue = ConstValue.extractBits(8, J * 8); | ||
| if (ExtractValue != 0x00 && ExtractValue != 0xFF) | ||
| return false; | ||
| if (ExtractValue == 0xFF) | ||
| BMI.setBit(J); | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| // If this is a case we can't handle, return null and let the default | ||
| // expansion code take care of it. If we CAN select this case, and if it | ||
| // selects to a single instruction, return Op. Otherwise, if we can codegen | ||
|
|
@@ -9591,6 +9622,24 @@ SDValue PPCTargetLowering::LowerBUILD_VECTOR(SDValue Op, | |
| BuildVectorSDNode *BVN = dyn_cast<BuildVectorSDNode>(Op.getNode()); | ||
| assert(BVN && "Expected a BuildVectorSDNode in LowerBUILD_VECTOR"); | ||
|
|
||
| if(Subtarget.hasP10Vector()) { | ||
| APInt BMI(32, 0); | ||
| // If the value of the vector is all zeros or all ones, | ||
| // we do not convert it to MTVSRBMI. | ||
| // The xxleqv instruction sets a vector with all ones. | ||
| // The xxlxor instruction sets a vector with all zeros. | ||
| if (isValidMtVsrbmi(BMI, *BVN) && BMI != 0 && BMI!=0xffff ) { | ||
| SDValue SDConstant= DAG.getTargetConstant(BMI, dl, MVT::i32); | ||
|
||
| MachineSDNode* MSDNode = DAG.getMachineNode(PPC::MTVSRBMI, dl,MVT::v16i8, SDConstant); | ||
|
||
| SDValue SDV = SDValue(MSDNode,0); | ||
|
||
| EVT DVT = BVN->getValueType(0); | ||
| EVT SVT = SDV.getValueType(); | ||
| if (SVT != DVT ) { | ||
| SDV = DAG.getNode(ISD::BITCAST, dl, DVT, SDV); | ||
|
||
| } | ||
| return SDV; | ||
| } | ||
| } | ||
| // Check if this is a splat of a constant value. | ||
| APInt APSplatBits, APSplatUndef; | ||
| unsigned SplatBitSize; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The instruction uses bmi but instruction names are short. Maybe use BitMask for parameter.