@@ -670,17 +670,6 @@ class InnerLoopVectorizer {
670
670
// / running the verifier. Return the preheader of the completed vector loop.
671
671
BasicBlock *completeLoopSkeleton ();
672
672
673
- // / Collect poison-generating recipes that may generate a poison value that is
674
- // / used after vectorization, even when their operands are not poison. Those
675
- // / recipes meet the following conditions:
676
- // / * Contribute to the address computation of a recipe generating a widen
677
- // / memory load/store (VPWidenMemoryInstructionRecipe or
678
- // / VPInterleaveRecipe).
679
- // / * Such a widen memory load/store has at least one underlying Instruction
680
- // / that is in a basic block that needs predication and after vectorization
681
- // / the generated instruction won't be predicated.
682
- void collectPoisonGeneratingRecipes (VPTransformState &State);
683
-
684
673
// / Allow subclasses to override and print debug traces before/after vplan
685
674
// / execution, when trace information is requested.
686
675
virtual void printDebugTracesAtStart (){};
@@ -1069,91 +1058,6 @@ static std::string getDebugLocString(const Loop *L) {
1069
1058
}
1070
1059
#endif
1071
1060
1072
- void InnerLoopVectorizer::collectPoisonGeneratingRecipes (
1073
- VPTransformState &State) {
1074
-
1075
- // Collect recipes in the backward slice of `Root` that may generate a poison
1076
- // value that is used after vectorization.
1077
- SmallPtrSet<VPRecipeBase *, 16 > Visited;
1078
- auto collectPoisonGeneratingInstrsInBackwardSlice ([&](VPRecipeBase *Root) {
1079
- SmallVector<VPRecipeBase *, 16 > Worklist;
1080
- Worklist.push_back (Root);
1081
-
1082
- // Traverse the backward slice of Root through its use-def chain.
1083
- while (!Worklist.empty ()) {
1084
- VPRecipeBase *CurRec = Worklist.back ();
1085
- Worklist.pop_back ();
1086
-
1087
- if (!Visited.insert (CurRec).second )
1088
- continue ;
1089
-
1090
- // Prune search if we find another recipe generating a widen memory
1091
- // instruction. Widen memory instructions involved in address computation
1092
- // will lead to gather/scatter instructions, which don't need to be
1093
- // handled.
1094
- if (isa<VPWidenMemoryInstructionRecipe>(CurRec) ||
1095
- isa<VPInterleaveRecipe>(CurRec) ||
1096
- isa<VPScalarIVStepsRecipe>(CurRec) ||
1097
- isa<VPCanonicalIVPHIRecipe>(CurRec) ||
1098
- isa<VPActiveLaneMaskPHIRecipe>(CurRec))
1099
- continue ;
1100
-
1101
- // This recipe contributes to the address computation of a widen
1102
- // load/store. If the underlying instruction has poison-generating flags,
1103
- // drop them directly.
1104
- if (auto *RecWithFlags = dyn_cast<VPRecipeWithIRFlags>(CurRec)) {
1105
- RecWithFlags->dropPoisonGeneratingFlags ();
1106
- } else {
1107
- Instruction *Instr = dyn_cast_or_null<Instruction>(
1108
- CurRec->getVPSingleValue ()->getUnderlyingValue ());
1109
- (void )Instr;
1110
- assert ((!Instr || !Instr->hasPoisonGeneratingFlags ()) &&
1111
- " found instruction with poison generating flags not covered by "
1112
- " VPRecipeWithIRFlags" );
1113
- }
1114
-
1115
- // Add new definitions to the worklist.
1116
- for (VPValue *operand : CurRec->operands ())
1117
- if (VPRecipeBase *OpDef = operand->getDefiningRecipe ())
1118
- Worklist.push_back (OpDef);
1119
- }
1120
- });
1121
-
1122
- // Traverse all the recipes in the VPlan and collect the poison-generating
1123
- // recipes in the backward slice starting at the address of a VPWidenRecipe or
1124
- // VPInterleaveRecipe.
1125
- auto Iter = vp_depth_first_deep (State.Plan ->getEntry ());
1126
- for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(Iter)) {
1127
- for (VPRecipeBase &Recipe : *VPBB) {
1128
- if (auto *WidenRec = dyn_cast<VPWidenMemoryInstructionRecipe>(&Recipe)) {
1129
- Instruction &UnderlyingInstr = WidenRec->getIngredient ();
1130
- VPRecipeBase *AddrDef = WidenRec->getAddr ()->getDefiningRecipe ();
1131
- if (AddrDef && WidenRec->isConsecutive () &&
1132
- Legal->blockNeedsPredication (UnderlyingInstr.getParent ()))
1133
- collectPoisonGeneratingInstrsInBackwardSlice (AddrDef);
1134
- } else if (auto *InterleaveRec = dyn_cast<VPInterleaveRecipe>(&Recipe)) {
1135
- VPRecipeBase *AddrDef = InterleaveRec->getAddr ()->getDefiningRecipe ();
1136
- if (AddrDef) {
1137
- // Check if any member of the interleave group needs predication.
1138
- const InterleaveGroup<Instruction> *InterGroup =
1139
- InterleaveRec->getInterleaveGroup ();
1140
- bool NeedPredication = false ;
1141
- for (int I = 0 , NumMembers = InterGroup->getNumMembers ();
1142
- I < NumMembers; ++I) {
1143
- Instruction *Member = InterGroup->getMember (I);
1144
- if (Member)
1145
- NeedPredication |=
1146
- Legal->blockNeedsPredication (Member->getParent ());
1147
- }
1148
-
1149
- if (NeedPredication)
1150
- collectPoisonGeneratingInstrsInBackwardSlice (AddrDef);
1151
- }
1152
- }
1153
- }
1154
- }
1155
- }
1156
-
1157
1061
namespace llvm {
1158
1062
1159
1063
// Loop vectorization cost-model hints how the scalar epilogue loop should be
@@ -7591,8 +7495,6 @@ LoopVectorizationPlanner::executePlan(
7591
7495
State.LVer ->prepareNoAliasMetadata ();
7592
7496
}
7593
7497
7594
- ILV.collectPoisonGeneratingRecipes (State);
7595
-
7596
7498
ILV.printDebugTracesAtStart ();
7597
7499
7598
7500
// ===------------------------------------------------===//
@@ -8869,6 +8771,10 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
8869
8771
// in ways that accessing values using original IR values is incorrect.
8870
8772
Plan->disableValue2VPValue ();
8871
8773
8774
+ VPlanTransforms::dropPoisonGeneratingRecipes (*Plan, [this ](BasicBlock *BB) {
8775
+ return Legal->blockNeedsPredication (BB);
8776
+ });
8777
+
8872
8778
// Sink users of fixed-order recurrence past the recipe defining the previous
8873
8779
// value and introduce FirstOrderRecurrenceSplice VPInstructions.
8874
8780
if (!VPlanTransforms::adjustFixedOrderRecurrences (*Plan, Builder))
0 commit comments