[llvm] [RISCV] Generalize (sub zext, zext) -> (sext (sub zext, zext)) to add (PR #86248)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 22 11:50:39 PDT 2024
================
@@ -12899,6 +12899,56 @@ static SDValue transformAddImmMulImm(SDNode *N, SelectionDAG &DAG,
return DAG.getNode(ISD::ADD, DL, VT, New1, DAG.getConstant(CB, DL, VT));
}
+// add (zext, zext) -> zext (add (zext, zext))
+// sub (zext, zext) -> sext (sub (zext, zext))
+//
+// where the sum of the extend widths match, and the the range of the bin op
+// fits inside the width of the narrower bin op. (For profitability on rvv, we
+// use a power of two for both inner and outer extend.)
+//
+// TODO: Extend this to other binary ops
+static SDValue combineBinOpOfZExt(SDNode *N, SelectionDAG &DAG,
+ const RISCVSubtarget &Subtarget) {
+
+ EVT VT = N->getValueType(0);
+ if (!VT.isVector() || !Subtarget.getTargetLowering()->isTypeLegal(VT))
----------------
topperc wrote:
You can use DAG.getTargetLowering() instead and drop the Subtarget.
https://github.com/llvm/llvm-project/pull/86248
More information about the llvm-commits
mailing list