diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h index 5dc905a3c407b..d86a81d4fb4c7 100644 --- a/llvm/lib/Transforms/Vectorize/VPlan.h +++ b/llvm/lib/Transforms/Vectorize/VPlan.h @@ -888,6 +888,8 @@ class VPSingleDefRecipe : public VPRecipeBase, public VPValue { return R && classof(R); } + virtual VPSingleDefRecipe *clone() override = 0; + /// Returns the underlying instruction. Instruction *getUnderlyingInstr() { return cast(getUnderlyingValue()); @@ -1248,7 +1250,7 @@ class VPInstruction : public VPRecipeWithIRFlags { VP_CLASSOF_IMPL(VPDef::VPInstructionSC) - VPRecipeBase *clone() override { + VPInstruction *clone() override { SmallVector Operands(operands()); auto *New = new VPInstruction(Opcode, Operands, getDebugLoc(), Name); New->transferFlags(*this); @@ -1335,7 +1337,7 @@ class VPWidenRecipe : public VPRecipeWithIRFlags { ~VPWidenRecipe() override = default; - VPRecipeBase *clone() override { + VPWidenRecipe *clone() override { auto *R = new VPWidenRecipe(*getUnderlyingInstr(), operands()); R->transferFlags(*this); return R; @@ -1380,7 +1382,7 @@ class VPWidenCastRecipe : public VPRecipeWithIRFlags { ~VPWidenCastRecipe() override = default; - VPRecipeBase *clone() override { + VPWidenCastRecipe *clone() override { if (auto *UV = getUnderlyingValue()) return new VPWidenCastRecipe(Opcode, getOperand(0), ResultTy, *cast(UV)); @@ -1420,7 +1422,7 @@ class VPScalarCastRecipe : public VPSingleDefRecipe { ~VPScalarCastRecipe() override = default; - VPRecipeBase *clone() override { + VPScalarCastRecipe *clone() override { return new VPScalarCastRecipe(Opcode, getOperand(0), ResultTy); } @@ -1465,7 +1467,7 @@ class VPWidenCallRecipe : public VPSingleDefRecipe { ~VPWidenCallRecipe() override = default; - VPRecipeBase *clone() override { + VPWidenCallRecipe *clone() override { return new VPWidenCallRecipe(*cast(getUnderlyingInstr()), operands(), VectorIntrinsicID, getDebugLoc(), Variant); @@ -1492,7 +1494,7 @@ struct VPWidenSelectRecipe : public VPSingleDefRecipe { ~VPWidenSelectRecipe() override = default; - VPRecipeBase *clone() override { + VPWidenSelectRecipe *clone() override { return new VPWidenSelectRecipe(*cast(getUnderlyingInstr()), operands()); } @@ -1540,7 +1542,7 @@ class VPWidenGEPRecipe : public VPRecipeWithIRFlags { ~VPWidenGEPRecipe() override = default; - VPRecipeBase *clone() override { + VPWidenGEPRecipe *clone() override { return new VPWidenGEPRecipe(cast(getUnderlyingInstr()), operands()); } @@ -1581,7 +1583,7 @@ class VPVectorPointerRecipe : public VPRecipeWithIRFlags { return true; } - VPRecipeBase *clone() override { + VPVectorPointerRecipe *clone() override { return new VPVectorPointerRecipe(getOperand(0), IndexedTy, IsReverse, isInBounds(), getDebugLoc()); } @@ -1696,7 +1698,7 @@ class VPWidenIntOrFpInductionRecipe : public VPHeaderPHIRecipe { ~VPWidenIntOrFpInductionRecipe() override = default; - VPRecipeBase *clone() override { + VPWidenIntOrFpInductionRecipe *clone() override { return new VPWidenIntOrFpInductionRecipe(IV, getStartValue(), getStepValue(), IndDesc, Trunc); } @@ -1771,7 +1773,7 @@ class VPWidenPointerInductionRecipe : public VPHeaderPHIRecipe { ~VPWidenPointerInductionRecipe() override = default; - VPRecipeBase *clone() override { + VPWidenPointerInductionRecipe *clone() override { return new VPWidenPointerInductionRecipe( cast(getUnderlyingInstr()), getOperand(0), getOperand(1), IndDesc, IsScalarAfterVectorization); @@ -1810,7 +1812,7 @@ class VPWidenPHIRecipe : public VPSingleDefRecipe { addOperand(Start); } - VPRecipeBase *clone() override { + VPWidenPHIRecipe *clone() override { llvm_unreachable("cloning not implemented yet"); } @@ -1853,7 +1855,7 @@ struct VPFirstOrderRecurrencePHIRecipe : public VPHeaderPHIRecipe { return R->getVPDefID() == VPDef::VPFirstOrderRecurrencePHISC; } - VPRecipeBase *clone() override { + VPFirstOrderRecurrencePHIRecipe *clone() override { return new VPFirstOrderRecurrencePHIRecipe( cast(getUnderlyingInstr()), *getOperand(0)); } @@ -1893,7 +1895,7 @@ class VPReductionPHIRecipe : public VPHeaderPHIRecipe { ~VPReductionPHIRecipe() override = default; - VPRecipeBase *clone() override { + VPReductionPHIRecipe *clone() override { auto *R = new VPReductionPHIRecipe(cast(getUnderlyingInstr()), RdxDesc, *getOperand(0), IsInLoop, IsOrdered); @@ -1940,7 +1942,7 @@ class VPBlendRecipe : public VPSingleDefRecipe { "Expected an odd number of operands"); } - VPRecipeBase *clone() override { + VPBlendRecipe *clone() override { SmallVector Ops(operands()); return new VPBlendRecipe(cast(getUnderlyingValue()), Ops); } @@ -2019,7 +2021,7 @@ class VPInterleaveRecipe : public VPRecipeBase { } ~VPInterleaveRecipe() override = default; - VPRecipeBase *clone() override { + VPInterleaveRecipe *clone() override { return new VPInterleaveRecipe(IG, getAddr(), getStoredValues(), getMask(), NeedsMaskForGaps); } @@ -2093,7 +2095,7 @@ class VPReductionRecipe : public VPSingleDefRecipe { ~VPReductionRecipe() override = default; - VPRecipeBase *clone() override { + VPReductionRecipe *clone() override { return new VPReductionRecipe(RdxDesc, getUnderlyingInstr(), getChainOp(), getVecOp(), getCondOp(), IsOrdered); } @@ -2142,7 +2144,7 @@ class VPReplicateRecipe : public VPRecipeWithIRFlags { ~VPReplicateRecipe() override = default; - VPRecipeBase *clone() override { + VPReplicateRecipe *clone() override { auto *Copy = new VPReplicateRecipe(getUnderlyingInstr(), operands(), IsUniform, isPredicated() ? getMask() : nullptr); @@ -2204,7 +2206,7 @@ class VPBranchOnMaskRecipe : public VPRecipeBase { addOperand(BlockInMask); } - VPRecipeBase *clone() override { + VPBranchOnMaskRecipe *clone() override { return new VPBranchOnMaskRecipe(getOperand(0)); } @@ -2255,7 +2257,7 @@ class VPPredInstPHIRecipe : public VPSingleDefRecipe { : VPSingleDefRecipe(VPDef::VPPredInstPHISC, PredV) {} ~VPPredInstPHIRecipe() override = default; - VPRecipeBase *clone() override { + VPPredInstPHIRecipe *clone() override { return new VPPredInstPHIRecipe(getOperand(0)); } @@ -2323,7 +2325,7 @@ class VPWidenMemoryInstructionRecipe : public VPRecipeBase { setMask(Mask); } - VPRecipeBase *clone() override { + VPWidenMemoryInstructionRecipe *clone() override { if (isStore()) return new VPWidenMemoryInstructionRecipe( cast(Ingredient), getAddr(), getStoredValue(), getMask(), @@ -2399,7 +2401,9 @@ class VPExpandSCEVRecipe : public VPSingleDefRecipe { ~VPExpandSCEVRecipe() override = default; - VPRecipeBase *clone() override { return new VPExpandSCEVRecipe(Expr, SE); } + VPExpandSCEVRecipe *clone() override { + return new VPExpandSCEVRecipe(Expr, SE); + } VP_CLASSOF_IMPL(VPDef::VPExpandSCEVSC) @@ -2426,7 +2430,7 @@ class VPCanonicalIVPHIRecipe : public VPHeaderPHIRecipe { ~VPCanonicalIVPHIRecipe() override = default; - VPRecipeBase *clone() override { + VPCanonicalIVPHIRecipe *clone() override { auto *R = new VPCanonicalIVPHIRecipe(getOperand(0), getDebugLoc()); R->addOperand(getBackedgeValue()); return R; @@ -2484,7 +2488,7 @@ class VPActiveLaneMaskPHIRecipe : public VPHeaderPHIRecipe { ~VPActiveLaneMaskPHIRecipe() override = default; - VPRecipeBase *clone() override { + VPActiveLaneMaskPHIRecipe *clone() override { return new VPActiveLaneMaskPHIRecipe(getOperand(0), getDebugLoc()); } @@ -2551,7 +2555,7 @@ class VPWidenCanonicalIVRecipe : public VPSingleDefRecipe { ~VPWidenCanonicalIVRecipe() override = default; - VPRecipeBase *clone() override { + VPWidenCanonicalIVRecipe *clone() override { return new VPWidenCanonicalIVRecipe( cast(getOperand(0))); } @@ -2602,7 +2606,7 @@ class VPDerivedIVRecipe : public VPSingleDefRecipe { ~VPDerivedIVRecipe() override = default; - VPRecipeBase *clone() override { + VPDerivedIVRecipe *clone() override { return new VPDerivedIVRecipe(Kind, FPBinOp, getStartValue(), getOperand(1), getStepValue()); } @@ -2656,7 +2660,7 @@ class VPScalarIVStepsRecipe : public VPRecipeWithIRFlags { ~VPScalarIVStepsRecipe() override = default; - VPRecipeBase *clone() override { + VPScalarIVStepsRecipe *clone() override { return new VPScalarIVStepsRecipe( getOperand(0), getOperand(1), InductionOpcode, hasFastMathFlags() ? getFastMathFlags() : FastMathFlags());