@@ -435,6 +435,8 @@ class AArch64DAGToDAGISel : public SelectionDAGISel {
435
435
bool trySelectCastFixedLengthToScalableVector (SDNode *N);
436
436
bool trySelectCastScalableToFixedLengthVector (SDNode *N);
437
437
438
+ bool trySelectXAR (SDNode *N);
439
+
438
440
// Include the pieces autogenerated from the target description.
439
441
#include " AArch64GenDAGISel.inc"
440
442
@@ -4273,6 +4275,40 @@ bool AArch64DAGToDAGISel::trySelectCastScalableToFixedLengthVector(SDNode *N) {
4273
4275
return true ;
4274
4276
}
4275
4277
4278
+ bool AArch64DAGToDAGISel::trySelectXAR (SDNode *N) {
4279
+ assert (N->getOpcode () == ISD::OR && " Expected OR instruction" );
4280
+
4281
+ SDValue N0 = N->getOperand (0 );
4282
+ SDValue N1 = N->getOperand (1 );
4283
+
4284
+ if (N0->getOpcode () != AArch64ISD::VSHL ||
4285
+ N1->getOpcode () != AArch64ISD::VLSHR)
4286
+ return false ;
4287
+
4288
+ if (N0->getOperand (0 ) != N1->getOperand (0 ) ||
4289
+ N1->getOperand (0 )->getOpcode () != ISD::XOR)
4290
+ return false ;
4291
+
4292
+ SDValue XOR = N0.getOperand (0 );
4293
+ SDValue R1 = XOR.getOperand (0 );
4294
+ SDValue R2 = XOR.getOperand (1 );
4295
+
4296
+ unsigned HsAmt = N0.getConstantOperandVal (1 );
4297
+ unsigned ShAmt = N1.getConstantOperandVal (1 );
4298
+
4299
+ SDLoc DL = SDLoc (N0.getOperand (1 ));
4300
+ SDValue Imm = CurDAG->getTargetConstant (
4301
+ ShAmt, DL, N0.getOperand (1 ).getValueType (), false );
4302
+
4303
+ if (ShAmt + HsAmt != 64 )
4304
+ return false ;
4305
+
4306
+ SDValue Ops[] = {R1, R2, Imm};
4307
+ CurDAG->SelectNodeTo (N, AArch64::XAR, N0.getValueType (), Ops);
4308
+
4309
+ return true ;
4310
+ }
4311
+
4276
4312
void AArch64DAGToDAGISel::Select (SDNode *Node) {
4277
4313
// If we have a custom node, we already have selected!
4278
4314
if (Node->isMachineOpcode ()) {
@@ -4336,6 +4372,8 @@ void AArch64DAGToDAGISel::Select(SDNode *Node) {
4336
4372
case ISD::OR:
4337
4373
if (tryBitfieldInsertOp (Node))
4338
4374
return ;
4375
+ if (Subtarget->hasSHA3 () && trySelectXAR (Node))
4376
+ return ;
4339
4377
break ;
4340
4378
4341
4379
case ISD::EXTRACT_SUBVECTOR: {
0 commit comments