@@ -4558,9 +4558,22 @@ bool AArch64DAGToDAGISel::trySelectXAR(SDNode *N) {
45584558 !TLI->isAllActivePredicate (*CurDAG, N1.getOperand (0 )))
45594559 return false ;
45604560
4561- SDValue XOR = N0.getOperand (1 );
4562- if (XOR.getOpcode () != ISD::XOR || XOR != N1.getOperand (1 ))
4563- return false ;
4561+ SDValue R1, R2;
4562+ if (N0.getOperand (1 ).getOpcode () != ISD::XOR) {
4563+ if (N0.getOperand (1 ) != N1.getOperand (1 ))
4564+ return false ;
4565+ SDLoc DL (N1->getOperand (0 ));
4566+ EVT VT = N1->getOperand (0 ).getValueType ();
4567+
4568+ SDValue Zero = CurDAG->getTargetConstant (0 , DL, MVT::i64 );
4569+ SDNode *MOV = CurDAG->getMachineNode (AArch64::MOVIv2d_ns, DL, VT, Zero);
4570+ SDValue MOVIV = SDValue (MOV, 0 );
4571+ R1 = N1->getOperand (0 );
4572+ R2 = MOVIV;
4573+ } else {
4574+ R1 = N0.getOperand (1 );
4575+ R2 = N1.getOperand (1 );
4576+ }
45644577
45654578 APInt ShlAmt, ShrAmt;
45664579 if (!ISD::isConstantSplatVector (N0.getOperand (2 ).getNode (), ShlAmt) ||
@@ -4574,7 +4587,7 @@ bool AArch64DAGToDAGISel::trySelectXAR(SDNode *N) {
45744587 SDValue Imm =
45754588 CurDAG->getTargetConstant (ShrAmt.getZExtValue (), DL, MVT::i32 );
45764589
4577- SDValue Ops[] = {XOR. getOperand ( 0 ), XOR. getOperand ( 1 ) , Imm};
4590+ SDValue Ops[] = {R1, R2 , Imm};
45784591 if (auto Opc = SelectOpcodeFromVT<SelectTypeKind::Int>(
45794592 VT, {AArch64::XAR_ZZZI_B, AArch64::XAR_ZZZI_H, AArch64::XAR_ZZZI_S,
45804593 AArch64::XAR_ZZZI_D})) {
@@ -4591,13 +4604,24 @@ bool AArch64DAGToDAGISel::trySelectXAR(SDNode *N) {
45914604 N1->getOpcode () != AArch64ISD::VLSHR)
45924605 return false ;
45934606
4594- if (N0->getOperand (0 ) != N1->getOperand (0 ) ||
4595- N1->getOperand (0 )->getOpcode () != ISD::XOR)
4607+ if (N0->getOperand (0 ) != N1->getOperand (0 ))
45964608 return false ;
45974609
4598- SDValue XOR = N0.getOperand (0 );
4599- SDValue R1 = XOR.getOperand (0 );
4600- SDValue R2 = XOR.getOperand (1 );
4610+ SDValue R1, R2;
4611+ if (N1->getOperand (0 )->getOpcode () != ISD::XOR) {
4612+ SDLoc DL (N1->getOperand (0 ));
4613+ EVT VT = N1->getOperand (0 ).getValueType ();
4614+
4615+ SDValue Zero = CurDAG->getTargetConstant (0 , DL, MVT::i64 );
4616+ SDNode *MOV = CurDAG->getMachineNode (AArch64::MOVIv2d_ns, DL, VT, Zero);
4617+ SDValue MOVIV = SDValue (MOV, 0 );
4618+ R1 = N1->getOperand (0 );
4619+ R2 = MOVIV;
4620+ } else {
4621+ SDValue XOR = N0.getOperand (0 );
4622+ R1 = XOR.getOperand (0 );
4623+ R2 = XOR.getOperand (1 );
4624+ }
46014625
46024626 unsigned HsAmt = N0.getConstantOperandVal (1 );
46034627 unsigned ShAmt = N1.getConstantOperandVal (1 );
0 commit comments