[llvm] [AArch64] Utilize `XAR` for certain vector rotates (PR #137629)

Rajveer Singh Bharadwaj via llvm-commits llvm-commits at lists.llvm.org
Tue May 6 01:50:45 PDT 2025


================
@@ -4558,9 +4558,27 @@ bool AArch64DAGToDAGISel::trySelectXAR(SDNode *N) {
         !TLI->isAllActivePredicate(*CurDAG, N1.getOperand(0)))
       return false;
 
-    SDValue XOR = N0.getOperand(1);
-    if (XOR.getOpcode() != ISD::XOR || XOR != N1.getOperand(1))
-      return false;
+    SDValue R1, R2;
+    if (N0.getOperand(1).getOpcode() != ISD::XOR) {
+      if (N0.getOperand(1) != N1.getOperand(1))
+        return false;
+      SDLoc DL(N1->getOperand(0));
+      EVT VT = N1->getOperand(0).getValueType();
+
+      SDValue Zero = CurDAG->getTargetConstant(0, DL, MVT::i64);
+      SDNode *MOV = CurDAG->getMachineNode(AArch64::MOVIv2d_ns, DL, VT, Zero);
+      SDValue MOVIV = SDValue(MOV, 0);
+
+      SDValue ZSub = CurDAG->getTargetConstant(AArch64::zsub, DL, MVT::i64);
+      SDNode *SubRegToReg = CurDAG->getMachineNode(AArch64::SUBREG_TO_REG, DL,
+                                                   MVT::i64, Zero, MOVIV, ZSub);
+
+      R1 = N1->getOperand(0);
+      R2 = SDValue(SubRegToReg, 0);
+    } else {
+      R1 = N0.getOperand(1);
+      R2 = N1.getOperand(1);
----------------
Rajveer100 wrote:

Done.

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


More information about the llvm-commits mailing list