[llvm] [RISCV] Add combines to form binop from tail insert idioms (PR #72675)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 28 07:43:58 PST 2023
================
@@ -14159,6 +14159,75 @@ static SDValue performBUILD_VECTORCombine(SDNode *N, SelectionDAG &DAG,
DAG.getBuildVector(VT, DL, RHSOps));
}
+static SDValue performINSERT_VECTOR_ELTCombine(SDNode *N, SelectionDAG &DAG,
+ const RISCVSubtarget &Subtarget,
+ const RISCVTargetLowering &TLI) {
+ SDValue InVec = N->getOperand(0);
+ SDValue InVal = N->getOperand(1);
+ SDValue EltNo = N->getOperand(2);
+ SDLoc DL(N);
+
+ EVT VT = InVec.getValueType();
+ if (VT.isScalableVector())
+ return SDValue();
+
+ if (!InVec.hasOneUse())
+ return SDValue();
+
+ // Given insert_vector_elt (binop a, VecC), (same_binop b, C2), Elt
+ // move the insert_vector_elts into the arms of the binop. Note that
+ // the new RHS must be a constant.
+ const unsigned InVecOpcode = InVec->getOpcode();
+ if (InVecOpcode == InVal->getOpcode() && TLI.isBinOp(InVecOpcode) &&
----------------
preames wrote:
I believe you're right. I'd prefer to leave this as is for this change as the interaction of the combines is rather fiddly. Happy to revisit in a follow up change though.
https://github.com/llvm/llvm-project/pull/72675
More information about the llvm-commits
mailing list