[llvm] [PowerPC] Implement a more efficient memcmp in cases where the length is known. (PR #158657)

Lei Huang via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 17 09:45:35 PDT 2025


================
@@ -15556,6 +15556,63 @@ SDValue PPCTargetLowering::combineSetCC(SDNode *N,
       SDValue Add = DAG.getNode(ISD::ADD, DL, OpVT, LHS, RHS.getOperand(1));
       return DAG.getSetCC(DL, VT, Add, DAG.getConstant(0, DL, OpVT), CC);
     }
+    if (Subtarget.hasVSX()) {
+      if (LHS.getOpcode() == ISD::LOAD && RHS.getOpcode() == ISD::LOAD &&
+          LHS.hasOneUse() && RHS.hasOneUse() &&
+          LHS.getValueType() == MVT::i128 && RHS.getValueType() == MVT::i128) {
+        SDLoc DL(N);
+        SelectionDAG &DAG = DCI.DAG;
+        auto *LA = dyn_cast<LoadSDNode>(LHS);
+        auto *LB = dyn_cast<LoadSDNode>(RHS);
+        if (!LA || !LB)
+          return SDValue();
----------------
lei137 wrote:

shouldn't all conditions that are not meet for this optimization results in the default behaviour for this function on line 15618 below?

https://github.com/llvm/llvm-project/pull/158657


More information about the llvm-commits mailing list