@@ -110,8 +110,7 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
110110 getActionDefinitionsBuilder (G_BSWAP)
111111 .legalFor ({s32, s64, v4s32, v2s32, v2s64})
112112 .widenScalarToNextPow2 (0 )
113- .clampScalar (0 , s32, s64)
114- .customIf (typeIs (0 , v2s16)); // custom lower as G_REV32 + G_LSHR
113+ .clampScalar (0 , s32, s64);
115114
116115 getActionDefinitionsBuilder ({G_ADD, G_SUB, G_MUL, G_AND, G_OR, G_XOR})
117116 .legalFor ({s32, s64, v2s32, v4s32, v4s16, v8s16, v16s8, v8s8})
@@ -791,8 +790,6 @@ bool AArch64LegalizerInfo::legalizeCustom(LegalizerHelper &Helper,
791790 case TargetOpcode::G_LOAD:
792791 case TargetOpcode::G_STORE:
793792 return legalizeLoadStore (MI, MRI, MIRBuilder, Observer);
794- case TargetOpcode::G_BSWAP:
795- return legalizeBSwap (MI, MRI, MIRBuilder);
796793 case TargetOpcode::G_SHL:
797794 case TargetOpcode::G_ASHR:
798795 case TargetOpcode::G_LSHR:
@@ -1047,46 +1044,6 @@ bool AArch64LegalizerInfo::legalizeLoadStore(
10471044 return true ;
10481045}
10491046
1050- bool AArch64LegalizerInfo::legalizeBSwap (MachineInstr &MI,
1051- MachineRegisterInfo &MRI,
1052- MachineIRBuilder &MIRBuilder) const {
1053- assert (MI.getOpcode () == TargetOpcode::G_BSWAP);
1054-
1055- // The <2 x half> case needs special lowering because there isn't an
1056- // instruction that does that directly. Instead, we widen to <8 x i8>
1057- // and emit a G_REV32 followed by a G_LSHR knowing that instruction selection
1058- // will later match them as:
1059- //
1060- // rev32.8b v0, v0
1061- // ushr.2s v0, v0, #16
1062- //
1063- // We could emit those here directly, but it seems better to keep things as
1064- // generic as possible through legalization, and avoid committing layering
1065- // violations by legalizing & selecting here at the same time.
1066-
1067- Register ValReg = MI.getOperand (1 ).getReg ();
1068- assert (LLT::fixed_vector (2 , 16 ) == MRI.getType (ValReg));
1069- const LLT v2s32 = LLT::fixed_vector (2 , 32 );
1070- const LLT v8s8 = LLT::fixed_vector (8 , 8 );
1071- const LLT s32 = LLT::scalar (32 );
1072-
1073- auto Undef = MIRBuilder.buildUndef (v8s8);
1074- auto Insert =
1075- MIRBuilder
1076- .buildInstr (TargetOpcode::INSERT_SUBREG, {v8s8}, {Undef, ValReg})
1077- .addImm (AArch64::ssub);
1078- auto Rev32 = MIRBuilder.buildInstr (AArch64::G_REV32, {v8s8}, {Insert});
1079- auto Bitcast = MIRBuilder.buildBitcast (v2s32, Rev32);
1080- auto Amt = MIRBuilder.buildConstant (v2s32, 16 );
1081- auto UShr =
1082- MIRBuilder.buildInstr (TargetOpcode::G_LSHR, {v2s32}, {Bitcast, Amt});
1083- auto Zero = MIRBuilder.buildConstant (s32, 0 );
1084- auto Extract = MIRBuilder.buildExtractVectorElement (s32, UShr, Zero);
1085- MIRBuilder.buildBitcast ({MI.getOperand (0 ).getReg ()}, Extract);
1086- MI.eraseFromParent ();
1087- return true ;
1088- }
1089-
10901047bool AArch64LegalizerInfo::legalizeVaArg (MachineInstr &MI,
10911048 MachineRegisterInfo &MRI,
10921049 MachineIRBuilder &MIRBuilder) const {
0 commit comments