[llvm] [RISCV] Select Zvkb VANDN for shorter constant loading sequences (PR #123345)

Piotr Fusik via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 20 08:26:17 PST 2025


================
@@ -3224,8 +3224,25 @@ bool RISCVDAGToDAGISel::selectInvLogicImm(SDValue N, SDValue &Val) {
 
   // Abandon this transform if the constant is needed elsewhere.
   for (const SDNode *U : N->users()) {
-    if (!ISD::isBitwiseLogicOp(U->getOpcode()))
+    switch (U->getOpcode()) {
+    case ISD::AND:
+    case ISD::OR:
+    case ISD::XOR:
+      if (!(Subtarget->hasStdExtZbb() || Subtarget->hasStdExtZbkb()))
+        return false;
+      break;
+    case RISCVISD::VMV_V_X_VL:
+      if (!Subtarget->hasStdExtZvkb())
+        return false;
+      if (!all_of(U->users(), [](const SDNode *V) {
+            return V->getOpcode() == ISD::AND ||
+                   V->getOpcode() == RISCVISD::AND_VL;
----------------
pfusik wrote:

Shall I check if that's not the passthru operand? If so, how to test it?

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


More information about the llvm-commits mailing list