Skip to content

Commit 478c420

Browse files
committed
[VPlan] Update recipe ::clone definitions to use cloned tys (NFC).
Update definitions on ::clone in recipe sub-types to use the sub-type as return type. This avoids typecasts down to the cloned type in some cases.
1 parent 32b95a3 commit 478c420

File tree

1 file changed

+30
-26
lines changed
  • llvm/lib/Transforms/Vectorize

1 file changed

+30
-26
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,8 @@ class VPSingleDefRecipe : public VPRecipeBase, public VPValue {
888888
return R && classof(R);
889889
}
890890

891+
virtual VPSingleDefRecipe *clone() override = 0;
892+
891893
/// Returns the underlying instruction.
892894
Instruction *getUnderlyingInstr() {
893895
return cast<Instruction>(getUnderlyingValue());
@@ -1248,7 +1250,7 @@ class VPInstruction : public VPRecipeWithIRFlags {
12481250

12491251
VP_CLASSOF_IMPL(VPDef::VPInstructionSC)
12501252

1251-
VPRecipeBase *clone() override {
1253+
VPInstruction *clone() override {
12521254
SmallVector<VPValue *, 2> Operands(operands());
12531255
auto *New = new VPInstruction(Opcode, Operands, getDebugLoc(), Name);
12541256
New->transferFlags(*this);
@@ -1335,7 +1337,7 @@ class VPWidenRecipe : public VPRecipeWithIRFlags {
13351337

13361338
~VPWidenRecipe() override = default;
13371339

1338-
VPRecipeBase *clone() override {
1340+
VPWidenRecipe *clone() override {
13391341
auto *R = new VPWidenRecipe(*getUnderlyingInstr(), operands());
13401342
R->transferFlags(*this);
13411343
return R;
@@ -1380,7 +1382,7 @@ class VPWidenCastRecipe : public VPRecipeWithIRFlags {
13801382

13811383
~VPWidenCastRecipe() override = default;
13821384

1383-
VPRecipeBase *clone() override {
1385+
VPWidenCastRecipe *clone() override {
13841386
if (auto *UV = getUnderlyingValue())
13851387
return new VPWidenCastRecipe(Opcode, getOperand(0), ResultTy,
13861388
*cast<CastInst>(UV));
@@ -1420,7 +1422,7 @@ class VPScalarCastRecipe : public VPSingleDefRecipe {
14201422

14211423
~VPScalarCastRecipe() override = default;
14221424

1423-
VPRecipeBase *clone() override {
1425+
VPScalarCastRecipe *clone() override {
14241426
return new VPScalarCastRecipe(Opcode, getOperand(0), ResultTy);
14251427
}
14261428

@@ -1465,7 +1467,7 @@ class VPWidenCallRecipe : public VPSingleDefRecipe {
14651467

14661468
~VPWidenCallRecipe() override = default;
14671469

1468-
VPRecipeBase *clone() override {
1470+
VPWidenCallRecipe *clone() override {
14691471
return new VPWidenCallRecipe(*cast<CallInst>(getUnderlyingInstr()),
14701472
operands(), VectorIntrinsicID, getDebugLoc(),
14711473
Variant);
@@ -1492,7 +1494,7 @@ struct VPWidenSelectRecipe : public VPSingleDefRecipe {
14921494

14931495
~VPWidenSelectRecipe() override = default;
14941496

1495-
VPRecipeBase *clone() override {
1497+
VPWidenSelectRecipe *clone() override {
14961498
return new VPWidenSelectRecipe(*cast<SelectInst>(getUnderlyingInstr()),
14971499
operands());
14981500
}
@@ -1540,7 +1542,7 @@ class VPWidenGEPRecipe : public VPRecipeWithIRFlags {
15401542

15411543
~VPWidenGEPRecipe() override = default;
15421544

1543-
VPRecipeBase *clone() override {
1545+
VPWidenGEPRecipe *clone() override {
15441546
return new VPWidenGEPRecipe(cast<GetElementPtrInst>(getUnderlyingInstr()),
15451547
operands());
15461548
}
@@ -1581,7 +1583,7 @@ class VPVectorPointerRecipe : public VPRecipeWithIRFlags {
15811583
return true;
15821584
}
15831585

1584-
VPRecipeBase *clone() override {
1586+
VPVectorPointerRecipe *clone() override {
15851587
return new VPVectorPointerRecipe(getOperand(0), IndexedTy, IsReverse,
15861588
isInBounds(), getDebugLoc());
15871589
}
@@ -1696,7 +1698,7 @@ class VPWidenIntOrFpInductionRecipe : public VPHeaderPHIRecipe {
16961698

16971699
~VPWidenIntOrFpInductionRecipe() override = default;
16981700

1699-
VPRecipeBase *clone() override {
1701+
VPWidenIntOrFpInductionRecipe *clone() override {
17001702
return new VPWidenIntOrFpInductionRecipe(IV, getStartValue(),
17011703
getStepValue(), IndDesc, Trunc);
17021704
}
@@ -1771,7 +1773,7 @@ class VPWidenPointerInductionRecipe : public VPHeaderPHIRecipe {
17711773

17721774
~VPWidenPointerInductionRecipe() override = default;
17731775

1774-
VPRecipeBase *clone() override {
1776+
VPWidenPointerInductionRecipe *clone() override {
17751777
return new VPWidenPointerInductionRecipe(
17761778
cast<PHINode>(getUnderlyingInstr()), getOperand(0), getOperand(1),
17771779
IndDesc, IsScalarAfterVectorization);
@@ -1810,7 +1812,7 @@ class VPWidenPHIRecipe : public VPSingleDefRecipe {
18101812
addOperand(Start);
18111813
}
18121814

1813-
VPRecipeBase *clone() override {
1815+
VPWidenPHIRecipe *clone() override {
18141816
llvm_unreachable("cloning not implemented yet");
18151817
}
18161818

@@ -1853,7 +1855,7 @@ struct VPFirstOrderRecurrencePHIRecipe : public VPHeaderPHIRecipe {
18531855
return R->getVPDefID() == VPDef::VPFirstOrderRecurrencePHISC;
18541856
}
18551857

1856-
VPRecipeBase *clone() override {
1858+
VPFirstOrderRecurrencePHIRecipe *clone() override {
18571859
return new VPFirstOrderRecurrencePHIRecipe(
18581860
cast<PHINode>(getUnderlyingInstr()), *getOperand(0));
18591861
}
@@ -1893,7 +1895,7 @@ class VPReductionPHIRecipe : public VPHeaderPHIRecipe {
18931895

18941896
~VPReductionPHIRecipe() override = default;
18951897

1896-
VPRecipeBase *clone() override {
1898+
VPReductionPHIRecipe *clone() override {
18971899
auto *R =
18981900
new VPReductionPHIRecipe(cast<PHINode>(getUnderlyingInstr()), RdxDesc,
18991901
*getOperand(0), IsInLoop, IsOrdered);
@@ -1940,7 +1942,7 @@ class VPBlendRecipe : public VPSingleDefRecipe {
19401942
"Expected an odd number of operands");
19411943
}
19421944

1943-
VPRecipeBase *clone() override {
1945+
VPBlendRecipe *clone() override {
19441946
SmallVector<VPValue *> Ops(operands());
19451947
return new VPBlendRecipe(cast<PHINode>(getUnderlyingValue()), Ops);
19461948
}
@@ -2019,7 +2021,7 @@ class VPInterleaveRecipe : public VPRecipeBase {
20192021
}
20202022
~VPInterleaveRecipe() override = default;
20212023

2022-
VPRecipeBase *clone() override {
2024+
VPInterleaveRecipe *clone() override {
20232025
return new VPInterleaveRecipe(IG, getAddr(), getStoredValues(), getMask(),
20242026
NeedsMaskForGaps);
20252027
}
@@ -2093,7 +2095,7 @@ class VPReductionRecipe : public VPSingleDefRecipe {
20932095

20942096
~VPReductionRecipe() override = default;
20952097

2096-
VPRecipeBase *clone() override {
2098+
VPReductionRecipe *clone() override {
20972099
return new VPReductionRecipe(RdxDesc, getUnderlyingInstr(), getChainOp(),
20982100
getVecOp(), getCondOp(), IsOrdered);
20992101
}
@@ -2142,7 +2144,7 @@ class VPReplicateRecipe : public VPRecipeWithIRFlags {
21422144

21432145
~VPReplicateRecipe() override = default;
21442146

2145-
VPRecipeBase *clone() override {
2147+
VPReplicateRecipe *clone() override {
21462148
auto *Copy =
21472149
new VPReplicateRecipe(getUnderlyingInstr(), operands(), IsUniform,
21482150
isPredicated() ? getMask() : nullptr);
@@ -2204,7 +2206,7 @@ class VPBranchOnMaskRecipe : public VPRecipeBase {
22042206
addOperand(BlockInMask);
22052207
}
22062208

2207-
VPRecipeBase *clone() override {
2209+
VPBranchOnMaskRecipe *clone() override {
22082210
return new VPBranchOnMaskRecipe(getOperand(0));
22092211
}
22102212

@@ -2255,7 +2257,7 @@ class VPPredInstPHIRecipe : public VPSingleDefRecipe {
22552257
: VPSingleDefRecipe(VPDef::VPPredInstPHISC, PredV) {}
22562258
~VPPredInstPHIRecipe() override = default;
22572259

2258-
VPRecipeBase *clone() override {
2260+
VPPredInstPHIRecipe *clone() override {
22592261
return new VPPredInstPHIRecipe(getOperand(0));
22602262
}
22612263

@@ -2323,7 +2325,7 @@ class VPWidenMemoryInstructionRecipe : public VPRecipeBase {
23232325
setMask(Mask);
23242326
}
23252327

2326-
VPRecipeBase *clone() override {
2328+
VPWidenMemoryInstructionRecipe *clone() override {
23272329
if (isStore())
23282330
return new VPWidenMemoryInstructionRecipe(
23292331
cast<StoreInst>(Ingredient), getAddr(), getStoredValue(), getMask(),
@@ -2399,7 +2401,9 @@ class VPExpandSCEVRecipe : public VPSingleDefRecipe {
23992401

24002402
~VPExpandSCEVRecipe() override = default;
24012403

2402-
VPRecipeBase *clone() override { return new VPExpandSCEVRecipe(Expr, SE); }
2404+
VPExpandSCEVRecipe *clone() override {
2405+
return new VPExpandSCEVRecipe(Expr, SE);
2406+
}
24032407

24042408
VP_CLASSOF_IMPL(VPDef::VPExpandSCEVSC)
24052409

@@ -2426,7 +2430,7 @@ class VPCanonicalIVPHIRecipe : public VPHeaderPHIRecipe {
24262430

24272431
~VPCanonicalIVPHIRecipe() override = default;
24282432

2429-
VPRecipeBase *clone() override {
2433+
VPCanonicalIVPHIRecipe *clone() override {
24302434
auto *R = new VPCanonicalIVPHIRecipe(getOperand(0), getDebugLoc());
24312435
R->addOperand(getBackedgeValue());
24322436
return R;
@@ -2484,7 +2488,7 @@ class VPActiveLaneMaskPHIRecipe : public VPHeaderPHIRecipe {
24842488

24852489
~VPActiveLaneMaskPHIRecipe() override = default;
24862490

2487-
VPRecipeBase *clone() override {
2491+
VPActiveLaneMaskPHIRecipe *clone() override {
24882492
return new VPActiveLaneMaskPHIRecipe(getOperand(0), getDebugLoc());
24892493
}
24902494

@@ -2551,7 +2555,7 @@ class VPWidenCanonicalIVRecipe : public VPSingleDefRecipe {
25512555

25522556
~VPWidenCanonicalIVRecipe() override = default;
25532557

2554-
VPRecipeBase *clone() override {
2558+
VPWidenCanonicalIVRecipe *clone() override {
25552559
return new VPWidenCanonicalIVRecipe(
25562560
cast<VPCanonicalIVPHIRecipe>(getOperand(0)));
25572561
}
@@ -2602,7 +2606,7 @@ class VPDerivedIVRecipe : public VPSingleDefRecipe {
26022606

26032607
~VPDerivedIVRecipe() override = default;
26042608

2605-
VPRecipeBase *clone() override {
2609+
VPDerivedIVRecipe *clone() override {
26062610
return new VPDerivedIVRecipe(Kind, FPBinOp, getStartValue(), getOperand(1),
26072611
getStepValue());
26082612
}
@@ -2656,7 +2660,7 @@ class VPScalarIVStepsRecipe : public VPRecipeWithIRFlags {
26562660

26572661
~VPScalarIVStepsRecipe() override = default;
26582662

2659-
VPRecipeBase *clone() override {
2663+
VPScalarIVStepsRecipe *clone() override {
26602664
return new VPScalarIVStepsRecipe(
26612665
getOperand(0), getOperand(1), InductionOpcode,
26622666
hasFastMathFlags() ? getFastMathFlags() : FastMathFlags());

0 commit comments

Comments
 (0)