Skip to content

Commit 7e977ac

Browse files
committed
Responding to review comments
- minor cleanup - allow optimizing concat_vectors(sqdmulh,sqdmulh) -> sqdmulh - testing EVTs better Change-Id: I0404fb9900896050baac372b7f7ce3a5b03517b9
1 parent 657f8f7 commit 7e977ac

File tree

3 files changed

+22
-27
lines changed

3 files changed

+22
-27
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2392,6 +2392,15 @@ static bool isIntImmediate(const SDNode *N, uint64_t &Imm) {
23922392
return false;
23932393
}
23942394

2395+
bool isVectorizedBinOp(unsigned Opcode) {
2396+
switch (Opcode) {
2397+
case AArch64ISD::SQDMULH:
2398+
return true;
2399+
default:
2400+
return false;
2401+
}
2402+
}
2403+
23952404
// isOpcWithIntImmediate - This method tests to see if the node is a specific
23962405
// opcode and that it has a immediate integer right operand.
23972406
// If so Imm will receive the value.
@@ -20126,8 +20135,9 @@ static SDValue performConcatVectorsCombine(SDNode *N,
2012620135
// size, combine into an binop of two contacts of the source vectors. eg:
2012720136
// concat(uhadd(a,b), uhadd(c, d)) -> uhadd(concat(a, c), concat(b, d))
2012820137
if (N->getNumOperands() == 2 && N0Opc == N1Opc && VT.is128BitVector() &&
20129-
DAG.getTargetLoweringInfo().isBinOp(N0Opc) && N0->hasOneUse() &&
20130-
N1->hasOneUse()) {
20138+
(DAG.getTargetLoweringInfo().isBinOp(N0Opc) ||
20139+
isVectorizedBinOp(N0Opc)) &&
20140+
N0->hasOneUse() && N1->hasOneUse()) {
2013120141
SDValue N00 = N0->getOperand(0);
2013220142
SDValue N01 = N0->getOperand(1);
2013320143
SDValue N10 = N1->getOperand(0);
@@ -20986,7 +20996,7 @@ static SDValue performBuildVectorCombine(SDNode *N,
2098620996
return SDValue();
2098720997
}
2098820998

20989-
// A special combine for the vqdmulh family of instructions.
20999+
// A special combine for the sqdmulh family of instructions.
2099021000
// smin( sra ( mul( sext v0, sext v1 ) ), SHIFT_AMOUNT ),
2099121001
// SATURATING_VAL ) can be reduced to sext(sqdmulh(...))
2099221002
static SDValue trySQDMULHCombine(SDNode *N, SelectionDAG &DAG) {
@@ -21043,24 +21053,20 @@ static SDValue trySQDMULHCombine(SDNode *N, SelectionDAG &DAG) {
2104321053
SDValue SExt0 = Mul.getOperand(0);
2104421054
SDValue SExt1 = Mul.getOperand(1);
2104521055

21046-
if (SExt0.getOpcode() != ISD::SIGN_EXTEND ||
21047-
SExt1.getOpcode() != ISD::SIGN_EXTEND ||
21048-
SExt0.getValueType() != SExt1.getValueType())
21049-
return SDValue();
21056+
EVT SExt0Type = SExt0.getOperand(0).getValueType();
21057+
EVT SExt1Type = SExt1.getOperand(0).getValueType();
2105021058

21051-
if ((ShiftAmt == 16 && (SExt0.getValueType() != MVT::v8i32 &&
21052-
SExt0.getValueType() != MVT::v4i32)) ||
21053-
(ShiftAmt == 32 && (SExt0.getValueType() != MVT::v4i64 &&
21054-
SExt0.getValueType() != MVT::v2i64)))
21059+
if (SExt0.getOpcode() != ISD::SIGN_EXTEND ||
21060+
SExt1.getOpcode() != ISD::SIGN_EXTEND || SExt0Type != SExt1Type ||
21061+
SExt0Type.getScalarType() != ScalarType ||
21062+
SExt0Type.getFixedSizeInBits() > 128)
2105521063
return SDValue();
2105621064

2105721065
SDValue V0 = SExt0.getOperand(0);
2105821066
SDValue V1 = SExt1.getOperand(0);
2105921067

2106021068
SDLoc DL(SMin);
21061-
EVT VecVT = N->getValueType(0);
21062-
SDValue SQDMULH = DAG.getNode(AArch64ISD::SQDMULH, DL, VecVT, V0, V1);
21063-
return DAG.getNode(ISD::SIGN_EXTEND, DL, N->getValueType(0), SQDMULH);
21069+
return DAG.getNode(AArch64ISD::SQDMULH, DL, SExt0Type, V0, V1);
2106421070
}
2106521071

2106621072
static SDValue performTruncateCombine(SDNode *N, SelectionDAG &DAG,

llvm/lib/Target/AArch64/AArch64InstrInfo.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9442,13 +9442,10 @@ def : Pat<(v4i32 (mulhu V128:$Rn, V128:$Rm)),
94429442

94439443
def : Pat<(v4i16 (AArch64sqdmulh (v4i16 V64:$Rn), (v4i16 V64:$Rm))),
94449444
(SQDMULHv4i16 V64:$Rn, V64:$Rm)>;
9445-
94469445
def : Pat<(v2i32 (AArch64sqdmulh (v2i32 V64:$Rn), (v2i32 V64:$Rm))),
94479446
(SQDMULHv2i32 V64:$Rn, V64:$Rm)>;
9448-
94499447
def : Pat<(v8i16 (AArch64sqdmulh (v8i16 V128:$Rn), (v8i16 V128:$Rm))),
94509448
(SQDMULHv8i16 V128:$Rn, V128:$Rm)>;
9451-
94529449
def : Pat<(v4i32 (AArch64sqdmulh (v4i32 V128:$Rn), (v4i32 V128:$Rm))),
94539450
(SQDMULHv4i32 V128:$Rn, V128:$Rm)>;
94549451

llvm/test/CodeGen/AArch64/saturating-vec-smull.ll

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,8 @@ define <4 x i32> @saturating_4xi32(<4 x i32> %a, <4 x i32> %b) {
6060
define <8 x i32> @saturating_8xi32(<8 x i32> %a, <8 x i32> %b) {
6161
; CHECK-LABEL: saturating_8xi32:
6262
; CHECK: // %bb.0:
63-
; CHECK-NEXT: ext v4.16b, v1.16b, v1.16b, #8
64-
; CHECK-NEXT: ext v5.16b, v3.16b, v3.16b, #8
65-
; CHECK-NEXT: ext v6.16b, v0.16b, v0.16b, #8
66-
; CHECK-NEXT: ext v7.16b, v2.16b, v2.16b, #8
67-
; CHECK-NEXT: sqdmulh v1.2s, v3.2s, v1.2s
68-
; CHECK-NEXT: sqdmulh v0.2s, v2.2s, v0.2s
69-
; CHECK-NEXT: sqdmulh v4.2s, v5.2s, v4.2s
70-
; CHECK-NEXT: sqdmulh v3.2s, v7.2s, v6.2s
71-
; CHECK-NEXT: mov v1.d[1], v4.d[0]
72-
; CHECK-NEXT: mov v0.d[1], v3.d[0]
63+
; CHECK-NEXT: sqdmulh v1.4s, v3.4s, v1.4s
64+
; CHECK-NEXT: sqdmulh v0.4s, v2.4s, v0.4s
7365
; CHECK-NEXT: ret
7466
%as = sext <8 x i32> %a to <8 x i64>
7567
%bs = sext <8 x i32> %b to <8 x i64>

0 commit comments

Comments
 (0)