Skip to content

Commit 0484baa

Browse files
committed
add hsat opcodes to canonicalizeShuffleMaskWithHorizOp
1 parent e4ef817 commit 0484baa

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40862,8 +40862,9 @@ static SDValue canonicalizeShuffleMaskWithHorizOp(
4086240862
}))
4086340863
return SDValue();
4086440864

40865-
bool isHoriz = (Opcode0 == X86ISD::FHADD || Opcode0 == X86ISD::HADD ||
40866-
Opcode0 == X86ISD::FHSUB || Opcode0 == X86ISD::HSUB);
40865+
bool isHoriz = (Opcode0 == X86ISD::FHADD || Opcode0 == X86ISD::FHSUB ||
40866+
Opcode0 == X86ISD::HADD || Opcode0 == X86ISD::HSUB ||
40867+
Opcode0 == X86ISD::HADDS || Opcode0 == X86ISD::HSUBS);
4086740868
bool isPack = (Opcode0 == X86ISD::PACKSS || Opcode0 == X86ISD::PACKUS);
4086840869
if (!isHoriz && !isPack)
4086940870
return SDValue();
@@ -54074,30 +54075,28 @@ static SDValue combineToHorizontalAddSub(SDNode *N, SelectionDAG &DAG,
5407454075
case ISD::SUB:
5407554076
case ISD::SADDSAT:
5407654077
case ISD::SSUBSAT:
54077-
if (IsSat && !((Subtarget.hasSSSE3() && VT == MVT::v8i16) ||
54078-
(Subtarget.hasAVX2() && VT == MVT::v16i16)))
54079-
break;
54080-
if (!IsSat &&
54081-
!(Subtarget.hasSSSE3() && (VT == MVT::v8i16 || VT == MVT::v4i32 ||
54082-
VT == MVT::v16i16 || VT == MVT::v8i32)))
54078+
if (!Subtarget.hasSSSE3())
5408354079
break;
54080+
if (VT == MVT::v8i16 || VT == MVT::v16i16 ||
54081+
(!IsSat && (VT == MVT::v4i32 || VT == MVT::v8i32))) {
5408454082

54085-
SDValue LHS = N->getOperand(0);
54086-
SDValue RHS = N->getOperand(1);
54087-
auto HorizOpcode = IsSat ? (IsAdd ? X86ISD::HADDS : X86ISD::HSUBS)
54088-
: (IsAdd ? X86ISD::HADD : X86ISD::HSUB);
54089-
if (isHorizontalBinOp(HorizOpcode, LHS, RHS, DAG, Subtarget, IsAdd,
54090-
PostShuffleMask, MergableHorizOp(HorizOpcode))) {
54091-
auto HOpBuilder = [HorizOpcode](SelectionDAG &DAG, const SDLoc &DL,
54092-
ArrayRef<SDValue> Ops) {
54093-
return DAG.getNode(HorizOpcode, DL, Ops[0].getValueType(), Ops);
54094-
};
54095-
SDValue HorizBinOp = SplitOpsAndApply(DAG, Subtarget, SDLoc(N), VT,
54096-
{LHS, RHS}, HOpBuilder);
54097-
if (!PostShuffleMask.empty())
54098-
HorizBinOp = DAG.getVectorShuffle(VT, SDLoc(HorizBinOp), HorizBinOp,
54099-
DAG.getUNDEF(VT), PostShuffleMask);
54100-
return HorizBinOp;
54083+
SDValue LHS = N->getOperand(0);
54084+
SDValue RHS = N->getOperand(1);
54085+
auto HorizOpcode = IsSat ? (IsAdd ? X86ISD::HADDS : X86ISD::HSUBS)
54086+
: (IsAdd ? X86ISD::HADD : X86ISD::HSUB);
54087+
if (isHorizontalBinOp(HorizOpcode, LHS, RHS, DAG, Subtarget, IsAdd,
54088+
PostShuffleMask, MergableHorizOp(HorizOpcode))) {
54089+
auto HOpBuilder = [HorizOpcode](SelectionDAG &DAG, const SDLoc &DL,
54090+
ArrayRef<SDValue> Ops) {
54091+
return DAG.getNode(HorizOpcode, DL, Ops[0].getValueType(), Ops);
54092+
};
54093+
SDValue HorizBinOp = SplitOpsAndApply(DAG, Subtarget, SDLoc(N), VT,
54094+
{LHS, RHS}, HOpBuilder);
54095+
if (!PostShuffleMask.empty())
54096+
HorizBinOp = DAG.getVectorShuffle(VT, SDLoc(HorizBinOp), HorizBinOp,
54097+
DAG.getUNDEF(VT), PostShuffleMask);
54098+
return HorizBinOp;
54099+
}
5410154100
}
5410254101
break;
5410354102
}

0 commit comments

Comments
 (0)