Skip to content

Commit b4399bc

Browse files
committed
Move static function to method on VPInstruction
1 parent 2759c77 commit b4399bc

File tree

2 files changed

+24
-25
lines changed

2 files changed

+24
-25
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,6 +1351,28 @@ class VPInstruction : public VPRecipeWithIRFlags,
13511351
}
13521352
}
13531353

1354+
/// Returns true if the underlying opcode may read from or write to memory.
1355+
bool opcodeMayReadOrWriteFromMemory() const {
1356+
if (Instruction::isBinaryOp(getOpcode()))
1357+
return false;
1358+
switch (getOpcode()) {
1359+
case Instruction::Or:
1360+
case Instruction::ICmp:
1361+
case Instruction::Select:
1362+
case VPInstruction::AnyOf:
1363+
case VPInstruction::Not:
1364+
case VPInstruction::CalculateTripCountMinusVF:
1365+
case VPInstruction::CanonicalIVIncrementForPart:
1366+
case VPInstruction::ExtractFromEnd:
1367+
case VPInstruction::FirstOrderRecurrenceSplice:
1368+
case VPInstruction::LogicalAnd:
1369+
case VPInstruction::PtrAdd:
1370+
return false;
1371+
default:
1372+
return true;
1373+
}
1374+
}
1375+
13541376
/// Returns true if the recipe only uses the first lane of operand \p Op.
13551377
bool onlyFirstLaneUsed(const VPValue *Op) const override;
13561378

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,32 +48,10 @@ extern cl::opt<unsigned> ForceTargetInstructionCost;
4848
#define LV_NAME "loop-vectorize"
4949
#define DEBUG_TYPE LV_NAME
5050

51-
static bool opcodeMayReadOrWriteFromMemory(unsigned Opcode) {
52-
if (Instruction::isBinaryOp(Opcode))
53-
return false;
54-
switch (Opcode) {
55-
case Instruction::Or:
56-
case Instruction::ICmp:
57-
case Instruction::Select:
58-
case VPInstruction::AnyOf:
59-
case VPInstruction::Not:
60-
case VPInstruction::CalculateTripCountMinusVF:
61-
case VPInstruction::CanonicalIVIncrementForPart:
62-
case VPInstruction::ExtractFromEnd:
63-
case VPInstruction::FirstOrderRecurrenceSplice:
64-
case VPInstruction::LogicalAnd:
65-
case VPInstruction::PtrAdd:
66-
return false;
67-
default:
68-
return true;
69-
}
70-
}
71-
7251
bool VPRecipeBase::mayWriteToMemory() const {
7352
switch (getVPDefID()) {
7453
case VPInstructionSC:
75-
return opcodeMayReadOrWriteFromMemory(
76-
cast<VPInstruction>(this)->getOpcode());
54+
return cast<VPInstruction>(this)->opcodeMayReadOrWriteFromMemory();
7755
case VPInterleaveSC:
7856
return cast<VPInterleaveRecipe>(this)->getNumStoreOperands() > 0;
7957
case VPWidenStoreEVLSC:
@@ -121,8 +99,7 @@ bool VPRecipeBase::mayWriteToMemory() const {
12199
bool VPRecipeBase::mayReadFromMemory() const {
122100
switch (getVPDefID()) {
123101
case VPInstructionSC:
124-
return opcodeMayReadOrWriteFromMemory(
125-
cast<VPInstruction>(this)->getOpcode());
102+
return cast<VPInstruction>(this)->opcodeMayReadOrWriteFromMemory();
126103
case VPWidenLoadEVLSC:
127104
case VPWidenLoadSC:
128105
return true;

0 commit comments

Comments
 (0)