}
// Return true if the target wants to transform Op(Splat(X)) -> Splat(Op(X))
- virtual bool preferScalarizeSplat(unsigned Opc) const { return true; }
+ virtual bool preferScalarizeSplat(SDNode *N) const { return true; }
/// Return true if the target wants to use the optimization that
/// turns ext(promotableInst1(...(promotableInstN(load)))) into
(N0.getOpcode() == ISD::SPLAT_VECTOR ||
TLI.isExtractVecEltCheap(VT, Index0)) &&
TLI.isOperationLegalOrCustom(Opcode, EltVT) &&
- TLI.preferScalarizeSplat(Opcode)) {
+ TLI.preferScalarizeSplat(N)) {
SDValue IndexC = DAG.getVectorIdxConstant(Index0, DL);
SDValue Elt =
DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, SrcEltVT, Src0, IndexC);
return nullptr;
}
+
+bool AArch64TargetLowering::preferScalarizeSplat(SDNode *N) const {
+ unsigned Opc = N->getOpcode();
+ if (Opc == ISD::ZERO_EXTEND || Opc == ISD::SIGN_EXTEND ||
+ Opc == ISD::ANY_EXTEND) {
+ if (any_of(N->uses(),
+ [&](SDNode *Use) { return Use->getOpcode() == ISD::MUL; }))
+ return false;
+ }
+ return true;
+}
bool isConstantUnsignedBitfieldExtractLegal(unsigned Opc, LLT Ty1,
LLT Ty2) const override;
+
+ bool preferScalarizeSplat(SDNode *N) const override;
};
namespace AArch64 {
return OptSize && !VT.isVector();
}
-bool RISCVTargetLowering::preferScalarizeSplat(unsigned Opc) const {
+bool RISCVTargetLowering::preferScalarizeSplat(SDNode *N) const {
// Scalarize zero_ext and sign_ext might stop match to widening instruction in
// some situation.
+ unsigned Opc = N->getOpcode();
if (Opc == ISD::ZERO_EXTEND || Opc == ISD::SIGN_EXTEND)
return false;
return true;
bool isIntDivCheap(EVT VT, AttributeList Attr) const override;
- bool preferScalarizeSplat(unsigned Opc) const override;
+ bool preferScalarizeSplat(SDNode *N) const override;
bool softPromoteHalfType() const override { return true; }
return NewShiftOpcode == ISD::SHL;
}
-bool X86TargetLowering::preferScalarizeSplat(unsigned Opc) const {
- return Opc != ISD::FP_EXTEND;
+bool X86TargetLowering::preferScalarizeSplat(SDNode *N) const {
+ return N->getOpcode() != ISD::FP_EXTEND;
}
bool X86TargetLowering::shouldFoldConstantShiftPairToMask(
unsigned OldShiftOpcode, unsigned NewShiftOpcode,
SelectionDAG &DAG) const override;
- bool preferScalarizeSplat(unsigned Opc) const override;
+ bool preferScalarizeSplat(SDNode *N) const override;
bool shouldFoldConstantShiftPairToMask(const SDNode *N,
CombineLevel Level) const override;
ret void
}
+define void @extend_and_mul(i32 %0, <2 x i64> %1, ptr %2) #0 {
+; CHECK-LABEL: extend_and_mul:
+; CHECK: // %bb.0:
+; CHECK-NEXT: mov z1.s, w0
+; CHECK-NEXT: // kill: def $q0 killed $q0 def $z0
+; CHECK-NEXT: ptrue p0.d, vl2
+; CHECK-NEXT: uunpklo z1.d, z1.s
+; CHECK-NEXT: mul z0.d, p0/m, z0.d, z1.d
+; CHECK-NEXT: str q0, [x1]
+; CHECK-NEXT: ret
+ %broadcast.splatinsert2 = insertelement <2 x i32> poison, i32 %0, i64 0
+ %broadcast.splat3 = shufflevector <2 x i32> %broadcast.splatinsert2, <2 x i32> poison, <2 x i32> zeroinitializer
+ %4 = zext <2 x i32> %broadcast.splat3 to <2 x i64>
+ %5 = mul <2 x i64> %4, %1
+ store <2 x i64> %5, ptr %2, align 2
+ ret void
+}
+
+define void @extend_no_mul(i32 %0, <2 x i64> %1, ptr %2) #0 {
+; CHECK-LABEL: extend_no_mul:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: mov w8, w0
+; CHECK-NEXT: mov z0.d, x8
+; CHECK-NEXT: str q0, [x1]
+; CHECK-NEXT: ret
+entry:
+ %broadcast.splatinsert2 = insertelement <2 x i32> poison, i32 %0, i64 0
+ %broadcast.splat3 = shufflevector <2 x i32> %broadcast.splatinsert2, <2 x i32> poison, <2 x i32> zeroinitializer
+ %3 = zext <2 x i32> %broadcast.splat3 to <2 x i64>
+ store <2 x i64> %3, ptr %2, align 2
+ ret void
+}
+
attributes #0 = { nounwind "target-features"="+sve" }