diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 3caff5f4213939..077b7867ebc9c9 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -1446,27 +1446,27 @@ class LoopVectorizationCostModel { /// Returns true if the target machine supports masked store operation /// for the given \p DataType and kind of access to \p Ptr. - bool isLegalMaskedStore(Type *DataType, Value *Ptr, Align Alignment) { + bool isLegalMaskedStore(Type *DataType, Value *Ptr, Align Alignment) const { return Legal->isConsecutivePtr(Ptr) && TTI.isLegalMaskedStore(DataType, Alignment); } /// Returns true if the target machine supports masked load operation /// for the given \p DataType and kind of access to \p Ptr. - bool isLegalMaskedLoad(Type *DataType, Value *Ptr, Align Alignment) { + bool isLegalMaskedLoad(Type *DataType, Value *Ptr, Align Alignment) const { return Legal->isConsecutivePtr(Ptr) && TTI.isLegalMaskedLoad(DataType, Alignment); } /// Returns true if the target machine supports masked scatter operation /// for the given \p DataType. - bool isLegalMaskedScatter(Type *DataType, Align Alignment) { + bool isLegalMaskedScatter(Type *DataType, Align Alignment) const { return TTI.isLegalMaskedScatter(DataType, Alignment); } /// Returns true if the target machine supports masked gather operation /// for the given \p DataType. - bool isLegalMaskedGather(Type *DataType, Align Alignment) { + bool isLegalMaskedGather(Type *DataType, Align Alignment) const { return TTI.isLegalMaskedGather(DataType, Alignment); } @@ -1497,8 +1497,9 @@ class LoopVectorizationCostModel { /// instructions that may divide by zero. /// If a non-zero VF has been calculated, we check if I will be scalarized /// predication for that VF. - bool isScalarWithPredication(Instruction *I, - ElementCount VF = ElementCount::getFixed(1)); + bool + isScalarWithPredication(Instruction *I, + ElementCount VF = ElementCount::getFixed(1)) const; // Returns true if \p I is an instruction that will be predicated either // through scalar predication or masked load/store or masked gather/scatter. @@ -1558,7 +1559,7 @@ class LoopVectorizationCostModel { /// Returns true if all loop blocks should be masked to fold tail loop. bool foldTailByMasking() const { return FoldTailByMasking; } - bool blockNeedsPredication(BasicBlock *BB) { + bool blockNeedsPredication(BasicBlock *BB) const { return foldTailByMasking() || Legal->blockNeedsPredication(BB); } @@ -5198,8 +5199,8 @@ void LoopVectorizationCostModel::collectLoopScalars(ElementCount VF) { Scalars[VF].insert(Worklist.begin(), Worklist.end()); } -bool LoopVectorizationCostModel::isScalarWithPredication(Instruction *I, - ElementCount VF) { +bool LoopVectorizationCostModel::isScalarWithPredication( + Instruction *I, ElementCount VF) const { if (!blockNeedsPredication(I->getParent())) return false; switch(I->getOpcode()) {