[LV] Use IRBuilderBase in VPlan.h, remove IRBuilder.h include (NFC).

By using IRBuilderBase instead of IRBuilder<> a forward declaration can
be used instead of including IRBuilder.h
This commit is contained in:
Florian Hahn 2022-02-07 17:46:16 +00:00
parent 677182fe98
commit 5a72357697
No known key found for this signature in database
GPG Key ID: EEF712BB5E80EBBA
3 changed files with 24 additions and 21 deletions

View File

@ -525,7 +525,7 @@ public:
/// Set the debug location in the builder \p Ptr using the debug location in
/// \p V. If \p Ptr is None then it uses the class member's Builder.
void setDebugLocFromInst(const Value *V,
Optional<IRBuilder<> *> CustomBuilder = None);
Optional<IRBuilderBase *> CustomBuilder = None);
/// Fix the non-induction PHIs in the OrigPHIsToFix vector.
void fixNonInductionPHIs(VPTransformState &State);
@ -658,8 +658,8 @@ protected:
/// For pointer induction, returns StartValue[Index * StepValue].
/// FIXME: The newly created binary instructions should contain nsw/nuw
/// flags, which can be found from the original scalar operations.
Value *emitTransformedIndex(IRBuilder<> &B, Value *Index, ScalarEvolution *SE,
const DataLayout &DL,
Value *emitTransformedIndex(IRBuilderBase &B, Value *Index,
ScalarEvolution *SE, const DataLayout &DL,
const InductionDescriptor &ID,
BasicBlock *VectorHeader) const;
@ -989,8 +989,8 @@ static Instruction *getDebugLocFromInstOrOperands(Instruction *I) {
}
void InnerLoopVectorizer::setDebugLocFromInst(
const Value *V, Optional<IRBuilder<> *> CustomBuilder) {
IRBuilder<> *B = (CustomBuilder == None) ? &Builder : *CustomBuilder;
const Value *V, Optional<IRBuilderBase *> CustomBuilder) {
IRBuilderBase *B = (CustomBuilder == None) ? &Builder : *CustomBuilder;
if (const Instruction *Inst = dyn_cast_or_null<Instruction>(V)) {
const DILocation *DIL = Inst->getDebugLoc();
@ -1054,7 +1054,7 @@ static OptimizationRemarkAnalysis createLVAnalysis(const char *PassName,
namespace llvm {
/// Return a value for Step multiplied by VF.
Value *createStepForVF(IRBuilder<> &B, Type *Ty, ElementCount VF,
Value *createStepForVF(IRBuilderBase &B, Type *Ty, ElementCount VF,
int64_t Step) {
assert(Ty->isIntegerTy() && "Expected an integer step");
Constant *StepVal = ConstantInt::get(Ty, Step * VF.getKnownMinValue());
@ -1062,12 +1062,13 @@ Value *createStepForVF(IRBuilder<> &B, Type *Ty, ElementCount VF,
}
/// Return the runtime value for VF.
Value *getRuntimeVF(IRBuilder<> &B, Type *Ty, ElementCount VF) {
Value *getRuntimeVF(IRBuilderBase &B, Type *Ty, ElementCount VF) {
Constant *EC = ConstantInt::get(Ty, VF.getKnownMinValue());
return VF.isScalable() ? B.CreateVScale(EC) : EC;
}
static Value *getRuntimeVFAsFloat(IRBuilder<> &B, Type *FTy, ElementCount VF) {
static Value *getRuntimeVFAsFloat(IRBuilderBase &B, Type *FTy,
ElementCount VF) {
assert(FTy->isFloatingPointTy() && "Expected floating point type!");
Type *IntTy = IntegerType::get(FTy->getContext(), FTy->getScalarSizeInBits());
Value *RuntimeVF = getRuntimeVF(B, IntTy, VF);
@ -2337,7 +2338,7 @@ Value *InnerLoopVectorizer::getBroadcastInstrs(Value *V) {
/// \p Opcode is relevant for FP induction variable.
static Value *getStepVector(Value *Val, Value *StartIdx, Value *Step,
Instruction::BinaryOps BinOp, ElementCount VF,
IRBuilder<> &Builder) {
IRBuilderBase &Builder) {
assert(VF.isVector() && "only vector VFs are supported");
// Create and check the types.
@ -2388,7 +2389,7 @@ static Value *getStepVector(Value *Val, Value *StartIdx, Value *Step,
void InnerLoopVectorizer::createVectorIntOrFpInductionPHI(
const InductionDescriptor &II, Value *Step, Value *Start,
Instruction *EntryVal, VPValue *Def, VPTransformState &State) {
IRBuilder<> &Builder = State.Builder;
IRBuilderBase &Builder = State.Builder;
assert((isa<PHINode>(EntryVal) || isa<TruncInst>(EntryVal)) &&
"Expected either an induction phi-node or a truncate of it!");
@ -2474,7 +2475,7 @@ void InnerLoopVectorizer::widenIntOrFpInduction(
Value *Start = Def->getStartValue()->getLiveInIRValue();
const InductionDescriptor &ID = Def->getInductionDescriptor();
TruncInst *Trunc = Def->getTruncInst();
IRBuilder<> &Builder = State.Builder;
IRBuilderBase &Builder = State.Builder;
assert(IV->getType() == ID.getStartValue()->getType() && "Types must match");
assert(!State.VF.isZero() && "VF must be non-zero");
@ -2577,7 +2578,7 @@ void InnerLoopVectorizer::buildScalarSteps(Value *ScalarIV, Value *Step,
const InductionDescriptor &ID,
VPValue *Def,
VPTransformState &State) {
IRBuilder<> &Builder = State.Builder;
IRBuilderBase &Builder = State.Builder;
// We shouldn't have to build scalar steps if we aren't vectorizing.
assert(State.VF.isVector() && "VF should be greater than one");
// Get the value type and ensure it and the step have the same integer type.
@ -3217,7 +3218,7 @@ BasicBlock *InnerLoopVectorizer::emitMemRuntimeChecks(Loop *L,
}
Value *InnerLoopVectorizer::emitTransformedIndex(
IRBuilder<> &B, Value *Index, ScalarEvolution *SE, const DataLayout &DL,
IRBuilderBase &B, Value *Index, ScalarEvolution *SE, const DataLayout &DL,
const InductionDescriptor &ID, BasicBlock *VectorHeader) const {
SCEVExpander Exp(*SE, DL, "induction");

View File

@ -27,6 +27,7 @@
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
@ -60,7 +61,7 @@ raw_ostream &llvm::operator<<(raw_ostream &OS, const VPValue &V) {
}
#endif
Value *VPLane::getAsRuntimeExpr(IRBuilder<> &Builder,
Value *VPLane::getAsRuntimeExpr(IRBuilderBase &Builder,
const ElementCount &VF) const {
switch (LaneKind) {
case VPLane::Kind::ScalableLast:
@ -640,7 +641,7 @@ void VPRecipeBase::moveBefore(VPBasicBlock &BB,
void VPInstruction::generateInstruction(VPTransformState &State,
unsigned Part) {
IRBuilder<> &Builder = State.Builder;
IRBuilderBase &Builder = State.Builder;
Builder.SetCurrentDebugLocation(DL);
if (Instruction::isBinaryOp(getOpcode())) {

View File

@ -40,7 +40,6 @@
#include "llvm/ADT/ilist_node.h"
#include "llvm/Analysis/VectorUtils.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/Support/InstructionCost.h"
#include <algorithm>
#include <cassert>
@ -54,6 +53,7 @@ class BasicBlock;
class DominatorTree;
class InductionDescriptor;
class InnerLoopVectorizer;
class IRBuilderBase;
class LoopInfo;
class raw_ostream;
class RecurrenceDescriptor;
@ -67,10 +67,11 @@ class VPlanSlp;
/// Returns a calculation for the total number of elements for a given \p VF.
/// For fixed width vectors this value is a constant, whereas for scalable
/// vectors it is an expression determined at runtime.
Value *getRuntimeVF(IRBuilder<> &B, Type *Ty, ElementCount VF);
Value *getRuntimeVF(IRBuilderBase &B, Type *Ty, ElementCount VF);
/// Return a value for Step multiplied by VF.
Value *createStepForVF(IRBuilder<> &B, Type *Ty, ElementCount VF, int64_t Step);
Value *createStepForVF(IRBuilderBase &B, Type *Ty, ElementCount VF,
int64_t Step);
/// A range of powers-of-2 vectorization factors with fixed start and
/// adjustable end. The range includes start and excludes end, e.g.,:
@ -151,7 +152,7 @@ public:
/// Returns an expression describing the lane index that can be used at
/// runtime.
Value *getAsRuntimeExpr(IRBuilder<> &Builder, const ElementCount &VF) const;
Value *getAsRuntimeExpr(IRBuilderBase &Builder, const ElementCount &VF) const;
/// Returns the Kind of lane offset.
Kind getKind() const { return LaneKind; }
@ -199,7 +200,7 @@ struct VPIteration {
/// needed for generating the output IR.
struct VPTransformState {
VPTransformState(ElementCount VF, unsigned UF, LoopInfo *LI,
DominatorTree *DT, IRBuilder<> &Builder,
DominatorTree *DT, IRBuilderBase &Builder,
InnerLoopVectorizer *ILV, VPlan *Plan)
: VF(VF), UF(UF), LI(LI), DT(DT), Builder(Builder), ILV(ILV), Plan(Plan) {
}
@ -337,7 +338,7 @@ struct VPTransformState {
DominatorTree *DT;
/// Hold a reference to the IRBuilder used to generate output IR code.
IRBuilder<> &Builder;
IRBuilderBase &Builder;
VPValue2ValueTy VPValue2Value;