Skip to content

Commit 009fb56

Browse files
committed
[AArch64] Add patterns for combining qxtn+rshr to qrshrn
Similar to bd861d0, this adds some patterns for converting signed and unsigned variants of rshr+qxtn to qrshrn.
1 parent dca43a1 commit 009fb56

File tree

3 files changed

+400
-6
lines changed

3 files changed

+400
-6
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5971,6 +5971,29 @@ SDValue AArch64TargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
59715971
Op.getOperand(1).getValueType(),
59725972
Op.getOperand(1), Op.getOperand(2)));
59735973
return SDValue();
5974+
case Intrinsic::aarch64_neon_sqrshrn:
5975+
if (Op.getValueType().isVector())
5976+
return DAG.getNode(
5977+
ISD::TRUNCATE_SSAT_S, dl, Op.getValueType(),
5978+
DAG.getNode(
5979+
AArch64ISD::SRSHR_I, dl, Op.getOperand(1).getValueType(),
5980+
Op.getOperand(1), Op.getOperand(2)));
5981+
return SDValue();
5982+
case Intrinsic::aarch64_neon_sqrshrun:
5983+
if (Op.getValueType().isVector())
5984+
return DAG.getNode(
5985+
ISD::TRUNCATE_SSAT_U, dl, Op.getValueType(),
5986+
DAG.getNode(
5987+
AArch64ISD::SRSHR_I, dl, Op.getOperand(1).getValueType(),
5988+
Op.getOperand(1), Op.getOperand(2)));
5989+
return SDValue();
5990+
case Intrinsic::aarch64_neon_uqrshrn:
5991+
if (Op.getValueType().isVector())
5992+
return DAG.getNode(
5993+
ISD::TRUNCATE_USAT_U, dl, Op.getValueType(),
5994+
DAG.getNode(
5995+
AArch64ISD::URSHR_I, dl, Op.getOperand(1).getValueType(), Op.getOperand(1), Op.getOperand(2)));
5996+
return SDValue();
59745997
case Intrinsic::aarch64_sve_whilelo:
59755998
return optimizeIncrementingWhile(Op, DAG, /*IsSigned=*/false,
59765999
/*IsEqual=*/false);

llvm/lib/Target/AArch64/AArch64InstrInfo.td

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8001,15 +8001,15 @@ def : Pat<(v1i64 (AArch64vsli (v1i64 FPR64:$Rd), (v1i64 FPR64:$Rn),
80018001
(i32 vecshiftL64:$imm))),
80028002
(SLId FPR64:$Rd, FPR64:$Rn, vecshiftL64:$imm)>;
80038003
defm SQRSHRN : SIMDVectorRShiftNarrowBHS<0, 0b10011, "sqrshrn",
8004-
int_aarch64_neon_sqrshrn>;
8004+
BinOpFrag<(truncssat_s (AArch64srshri node:$LHS, node:$RHS))>>;
80058005
defm SQRSHRUN: SIMDVectorRShiftNarrowBHS<1, 0b10001, "sqrshrun",
8006-
int_aarch64_neon_sqrshrun>;
8006+
BinOpFrag<(truncssat_u (AArch64srshri node:$LHS, node:$RHS))>>;
80078007
defm SQSHLU : SIMDVectorLShiftBHSD<1, 0b01100, "sqshlu", AArch64sqshlui>;
80088008
defm SQSHL : SIMDVectorLShiftBHSD<0, 0b01110, "sqshl", AArch64sqshli>;
80098009
defm SQSHRN : SIMDVectorRShiftNarrowBHS<0, 0b10010, "sqshrn",
8010-
BinOpFrag<(truncssat_s (AArch64vashr node:$LHS, node:$RHS))>>;
8010+
BinOpFrag<(truncssat_s (AArch64vashr node:$LHS, node:$RHS))>>;
80118011
defm SQSHRUN : SIMDVectorRShiftNarrowBHS<1, 0b10000, "sqshrun",
8012-
BinOpFrag<(truncssat_u (AArch64vashr node:$LHS, node:$RHS))>>;
8012+
BinOpFrag<(truncssat_u (AArch64vashr node:$LHS, node:$RHS))>>;
80138013
defm SRI : SIMDVectorRShiftBHSDTied<1, 0b01000, "sri", AArch64vsri>;
80148014
def : Pat<(v1i64 (AArch64vsri (v1i64 FPR64:$Rd), (v1i64 FPR64:$Rn),
80158015
(i32 vecshiftR64:$imm))),
@@ -8027,10 +8027,10 @@ defm SSRA : SIMDVectorRShiftBHSDTied<0, 0b00010, "ssra",
80278027
defm UCVTF : SIMDVectorRShiftToFP<1, 0b11100, "ucvtf",
80288028
int_aarch64_neon_vcvtfxu2fp>;
80298029
defm UQRSHRN : SIMDVectorRShiftNarrowBHS<1, 0b10011, "uqrshrn",
8030-
int_aarch64_neon_uqrshrn>;
8030+
BinOpFrag<(truncusat_u (AArch64urshri node:$LHS, node:$RHS))>>;
80318031
defm UQSHL : SIMDVectorLShiftBHSD<1, 0b01110, "uqshl", AArch64uqshli>;
80328032
defm UQSHRN : SIMDVectorRShiftNarrowBHS<1, 0b10010, "uqshrn",
8033-
BinOpFrag<(truncusat_u (AArch64vlshr node:$LHS, node:$RHS))>>;
8033+
BinOpFrag<(truncusat_u (AArch64vlshr node:$LHS, node:$RHS))>>;
80348034
defm URSHR : SIMDVectorRShiftBHSD<1, 0b00100, "urshr", AArch64urshri>;
80358035
defm URSRA : SIMDVectorRShiftBHSDTied<1, 0b00110, "ursra",
80368036
TriOpFrag<(add node:$LHS,

0 commit comments

Comments
 (0)