Skip to content

Commit

Permalink
Revert "[AArch64] Canonicalize ZERO_EXTEND to VSELECT"
Browse files Browse the repository at this point in the history
This reverts commit 43fe14c.
  • Loading branch information
NicolaLancellotti committed Nov 28, 2022
1 parent 1ea66ee commit 49cd18c
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 258 deletions.
24 changes: 1 addition & 23 deletions llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
Expand Up @@ -1209,7 +1209,6 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
setOperationAction(ISD::VECREDUCE_UMAX, VT, Custom);
setOperationAction(ISD::VECREDUCE_SMIN, VT, Custom);
setOperationAction(ISD::VECREDUCE_SMAX, VT, Custom);
setOperationAction(ISD::ZERO_EXTEND, VT, Custom);

setOperationAction(ISD::UMUL_LOHI, VT, Expand);
setOperationAction(ISD::SMUL_LOHI, VT, Expand);
Expand Down Expand Up @@ -5626,26 +5625,6 @@ static SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) {
return SDValue();
}

SDValue AArch64TargetLowering::LowerZERO_EXTEND(SDValue Op, SelectionDAG &DAG) const {
assert(Op->getOpcode() == ISD::ZERO_EXTEND && "Expected ZERO_EXTEND");

if (Op.getValueType().isFixedLengthVector())
return LowerFixedLengthVectorIntExtendToSVE(Op, DAG);

// Try to lower to VSELECT to allow zext to transform into
// a predicated instruction like add, sub or mul.
SDValue Value = Op->getOperand(0);
if (!Value->getValueType(0).isScalableVector() ||
Value->getValueType(0).getScalarType() != MVT::i1)
return SDValue();

SDLoc DL = SDLoc(Op);
EVT VT = Op->getValueType(0);
SDValue Ones = DAG.getConstant(1, DL, VT);
SDValue Zeros = DAG.getConstant(0, DL, VT);
return DAG.getNode(ISD::VSELECT, DL, VT, Value, Ones, Zeros);
}

SDValue AArch64TargetLowering::LowerOperation(SDValue Op,
SelectionDAG &DAG) const {
LLVM_DEBUG(dbgs() << "Custom lowering: ");
Expand Down Expand Up @@ -5858,9 +5837,8 @@ SDValue AArch64TargetLowering::LowerOperation(SDValue Op,
return LowerVSCALE(Op, DAG);
case ISD::ANY_EXTEND:
case ISD::SIGN_EXTEND:
return LowerFixedLengthVectorIntExtendToSVE(Op, DAG);
case ISD::ZERO_EXTEND:
return LowerZERO_EXTEND(Op, DAG);
return LowerFixedLengthVectorIntExtendToSVE(Op, DAG);
case ISD::SIGN_EXTEND_INREG: {
// Only custom lower when ExtraVT has a legal byte based element type.
EVT ExtraVT = cast<VTSDNode>(Op.getOperand(1))->getVT();
Expand Down
1 change: 0 additions & 1 deletion llvm/lib/Target/AArch64/AArch64ISelLowering.h
Expand Up @@ -937,7 +937,6 @@ class AArch64TargetLowering : public TargetLowering {
SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
SDValue LowerStore128(SDValue Op, SelectionDAG &DAG) const;
SDValue LowerABS(SDValue Op, SelectionDAG &DAG) const;
SDValue LowerZERO_EXTEND(SDValue Op, SelectionDAG &DAG) const;

SDValue LowerMGATHER(SDValue Op, SelectionDAG &DAG) const;
SDValue LowerMSCATTER(SDValue Op, SelectionDAG &DAG) const;
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
Expand Up @@ -513,13 +513,13 @@ let Predicates = [HasSVEorSME] in {
defm FNEG_ZPmZ : sve_int_un_pred_arit_1_fp<0b101, "fneg", AArch64fneg_mt>;

// zext(cmpeq(x, splat(0))) -> cnot(x)
def : Pat<(nxv16i8 (vselect (nxv16i1 (AArch64setcc_z (nxv16i1 (SVEAllActive):$Pg), nxv16i8:$Op2, (SVEDup0), SETEQ)), (nxv16i8 (splat_vector (i32 1))), (nxv16i8 (splat_vector (i32 0))))),
def : Pat<(nxv16i8 (zext (nxv16i1 (AArch64setcc_z (nxv16i1 (SVEAllActive):$Pg), nxv16i8:$Op2, (SVEDup0), SETEQ)))),
(CNOT_ZPmZ_B $Op2, $Pg, $Op2)>;
def : Pat<(nxv8i16 (vselect (nxv8i1 (AArch64setcc_z (nxv8i1 (SVEAllActive):$Pg), nxv8i16:$Op2, (SVEDup0), SETEQ)), (nxv8i16 (splat_vector (i32 1))), (nxv8i16 (splat_vector (i32 0))))),
def : Pat<(nxv8i16 (zext (nxv8i1 (AArch64setcc_z (nxv8i1 (SVEAllActive):$Pg), nxv8i16:$Op2, (SVEDup0), SETEQ)))),
(CNOT_ZPmZ_H $Op2, $Pg, $Op2)>;
def : Pat<(nxv4i32 (vselect (nxv4i1 (AArch64setcc_z (nxv4i1 (SVEAllActive):$Pg), nxv4i32:$Op2, (SVEDup0), SETEQ)), (nxv4i32 (splat_vector (i32 1))), (nxv4i32 (splat_vector (i32 0))))),
def : Pat<(nxv4i32 (zext (nxv4i1 (AArch64setcc_z (nxv4i1 (SVEAllActive):$Pg), nxv4i32:$Op2, (SVEDup0), SETEQ)))),
(CNOT_ZPmZ_S $Op2, $Pg, $Op2)>;
def : Pat<(nxv2i64 (vselect (nxv2i1 (AArch64setcc_z (nxv2i1 (SVEAllActive):$Pg), nxv2i64:$Op2, (SVEDup0), SETEQ)), (nxv2i64 (splat_vector (i64 1))), (nxv2i64 (splat_vector (i64 0))))),
def : Pat<(nxv2i64 (zext (nxv2i1 (AArch64setcc_z (nxv2i1 (SVEAllActive):$Pg), nxv2i64:$Op2, (SVEDup0), SETEQ)))),
(CNOT_ZPmZ_D $Op2, $Pg, $Op2)>;

defm SMAX_ZPmZ : sve_int_bin_pred_arit_1<0b000, "smax", "SMAX_ZPZZ", AArch64smax_m1, DestructiveBinaryComm>;
Expand Down
6 changes: 0 additions & 6 deletions llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
Expand Up @@ -1918,12 +1918,6 @@ InstructionCost AArch64TTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
{ ISD::BITCAST, MVT::nxv2i16, MVT::nxv2f16, 0 },
{ ISD::BITCAST, MVT::nxv4i16, MVT::nxv4f16, 0 },
{ ISD::BITCAST, MVT::nxv2i32, MVT::nxv2f32, 0 },

// Zero extends from nxvmi1 to nxvmiN.
{ ISD::ZERO_EXTEND, MVT::nxv2i64, MVT::nxv2i1, 1 },
{ ISD::ZERO_EXTEND, MVT::nxv4i32, MVT::nxv4i1, 1 },
{ ISD::ZERO_EXTEND, MVT::nxv8i16, MVT::nxv8i1, 1 },
{ ISD::ZERO_EXTEND, MVT::nxv16i8, MVT::nxv16i1, 1 },
};

if (const auto *Entry = ConvertCostTableLookup(ConversionTbl, ISD,
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/AArch64/SVEInstrFormats.td
Expand Up @@ -4753,6 +4753,8 @@ multiclass sve_int_dup_imm_pred_zero_inst<
(ins PPRAny:$Pg, cpyimm:$imm)>;
def : InstAlias<"mov $Zd, $Pg/z, $imm",
(!cast<Instruction>(NAME) zprty:$Zd, PPRAny:$Pg, cpyimm:$imm), 1>;
def : Pat<(intty (zext (predty PPRAny:$Ps1))),
(!cast<Instruction>(NAME) PPRAny:$Ps1, 1, 0)>;
def : Pat<(intty (sext (predty PPRAny:$Ps1))),
(!cast<Instruction>(NAME) PPRAny:$Ps1, -1, 0)>;
def : Pat<(intty (anyext (predty PPRAny:$Ps1))),
Expand Down
224 changes: 0 additions & 224 deletions llvm/test/CodeGen/AArch64/predicated-add-sub-mul.ll

This file was deleted.

0 comments on commit 49cd18c

Please sign in to comment.