@@ -48,27 +48,32 @@ 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+
5172bool VPRecipeBase::mayWriteToMemory () const {
5273 switch (getVPDefID ()) {
5374 case VPInstructionSC:
54- if (Instruction::isBinaryOp (cast<VPInstruction>(this )->getOpcode ()))
55- return false ;
56- switch (cast<VPInstruction>(this )->getOpcode ()) {
57- case Instruction::Or:
58- case Instruction::ICmp:
59- case Instruction::Select:
60- case VPInstruction::AnyOf:
61- case VPInstruction::Not:
62- case VPInstruction::CalculateTripCountMinusVF:
63- case VPInstruction::CanonicalIVIncrementForPart:
64- case VPInstruction::ExtractFromEnd:
65- case VPInstruction::FirstOrderRecurrenceSplice:
66- case VPInstruction::LogicalAnd:
67- case VPInstruction::PtrAdd:
68- return false ;
69- default :
70- return true ;
71- }
75+ return opcodeMayReadOrWriteFromMemory (
76+ cast<VPInstruction>(this )->getOpcode ());
7277 case VPInterleaveSC:
7378 return cast<VPInterleaveRecipe>(this )->getNumStoreOperands () > 0 ;
7479 case VPWidenStoreEVLSC:
@@ -116,24 +121,8 @@ bool VPRecipeBase::mayWriteToMemory() const {
116121bool VPRecipeBase::mayReadFromMemory () const {
117122 switch (getVPDefID ()) {
118123 case VPInstructionSC:
119- if (Instruction::isBinaryOp (cast<VPInstruction>(this )->getOpcode ()))
120- return false ;
121- switch (cast<VPInstruction>(this )->getOpcode ()) {
122- case Instruction::Or:
123- case Instruction::ICmp:
124- case Instruction::Select:
125- case VPInstruction::AnyOf:
126- case VPInstruction::Not:
127- case VPInstruction::CalculateTripCountMinusVF:
128- case VPInstruction::CanonicalIVIncrementForPart:
129- case VPInstruction::ExtractFromEnd:
130- case VPInstruction::FirstOrderRecurrenceSplice:
131- case VPInstruction::LogicalAnd:
132- case VPInstruction::PtrAdd:
133- return false ;
134- default :
135- return true ;
136- }
124+ return opcodeMayReadOrWriteFromMemory (
125+ cast<VPInstruction>(this )->getOpcode ());
137126 case VPWidenLoadEVLSC:
138127 case VPWidenLoadSC:
139128 return true ;
0 commit comments