1313#include " AArch64MachineFunctionInfo.h"
1414#include " AArch64TargetMachine.h"
1515#include " MCTargetDesc/AArch64AddressingModes.h"
16+ #include " MCTargetDesc/AArch64MCTargetDesc.h"
1617#include " llvm/ADT/APSInt.h"
1718#include " llvm/CodeGen/ISDOpcodes.h"
1819#include " llvm/CodeGen/SelectionDAGISel.h"
@@ -4558,9 +4559,19 @@ bool AArch64DAGToDAGISel::trySelectXAR(SDNode *N) {
45584559 !TLI->isAllActivePredicate (*CurDAG, N1.getOperand (0 )))
45594560 return false ;
45604561
4561- SDValue XOR = N0.getOperand (1 );
4562- if (XOR.getOpcode () != ISD::XOR || XOR != N1.getOperand (1 ))
4563- return false ;
4562+ SDValue R1, R2;
4563+ if (N0.getOperand (1 ).getOpcode () != ISD::XOR) {
4564+ if (N0.getOperand (1 ) != N1.getOperand (1 ))
4565+ return false ;
4566+ SDLoc DL (N1->getOperand (0 ));
4567+ SDValue Zero =
4568+ CurDAG->getConstant (0 , DL, N1->getOperand (0 ).getValueType ());
4569+ R1 = N1->getOperand (0 );
4570+ R2 = Zero;
4571+ } else {
4572+ R1 = N0.getOperand (1 );
4573+ R2 = N1.getOperand (1 );
4574+ }
45644575
45654576 APInt ShlAmt, ShrAmt;
45664577 if (!ISD::isConstantSplatVector (N0.getOperand (2 ).getNode (), ShlAmt) ||
@@ -4574,7 +4585,7 @@ bool AArch64DAGToDAGISel::trySelectXAR(SDNode *N) {
45744585 SDValue Imm =
45754586 CurDAG->getTargetConstant (ShrAmt.getZExtValue (), DL, MVT::i32 );
45764587
4577- SDValue Ops[] = {XOR. getOperand ( 0 ), XOR. getOperand ( 1 ) , Imm};
4588+ SDValue Ops[] = {R1, R2 , Imm};
45784589 if (auto Opc = SelectOpcodeFromVT<SelectTypeKind::Int>(
45794590 VT, {AArch64::XAR_ZZZI_B, AArch64::XAR_ZZZI_H, AArch64::XAR_ZZZI_S,
45804591 AArch64::XAR_ZZZI_D})) {
@@ -4591,13 +4602,20 @@ bool AArch64DAGToDAGISel::trySelectXAR(SDNode *N) {
45914602 N1->getOpcode () != AArch64ISD::VLSHR)
45924603 return false ;
45934604
4594- if (N0->getOperand (0 ) != N1->getOperand (0 ) ||
4595- N1->getOperand (0 )->getOpcode () != ISD::XOR)
4605+ if (N0->getOperand (0 ) != N1->getOperand (0 ))
45964606 return false ;
45974607
4598- SDValue XOR = N0.getOperand (0 );
4599- SDValue R1 = XOR.getOperand (0 );
4600- SDValue R2 = XOR.getOperand (1 );
4608+ SDValue R1, R2;
4609+ if (N1->getOperand (0 )->getOpcode () != ISD::XOR) {
4610+ SDLoc DL (N1->getOperand (0 ));
4611+ SDValue Zero = CurDAG->getConstant (0 , DL, N1->getOperand (0 ).getValueType ());
4612+ R1 = N1->getOperand (0 );
4613+ R2 = Zero;
4614+ } else {
4615+ SDValue XOR = N0.getOperand (0 );
4616+ R1 = XOR.getOperand (0 );
4617+ R2 = XOR.getOperand (1 );
4618+ }
46014619
46024620 unsigned HsAmt = N0.getConstantOperandVal (1 );
46034621 unsigned ShAmt = N1.getConstantOperandVal (1 );
0 commit comments