Commit 7480ccbf authored by Sjoerd Meijer's avatar Sjoerd Meijer
Browse files

[TTI] New target hook emitGetActiveLaneMask

This is split off from D79100 and adds a new target hook emitGetActiveLaneMask
that can be queried to check if the intrinsic @llvm.get.active.lane.mask() is
supported by the backend and if it should be emitted for a given loop.

See also commit rG7fb8a40e and its commit message for more details/context
on this new intrinsic.

Differential Revision: https://reviews.llvm.org/D80597
parent 82bb57c1
......@@ -524,6 +524,11 @@ public:
DominatorTree *DT,
const LoopAccessInfo *LAI) const;
/// Query the target whether lowering of the llvm.get.active.lane.mask
/// intrinsic is supported and if emitting it is desired for this loop.
bool emitGetActiveLaneMask(Loop *L, LoopInfo *LI, ScalarEvolution &SE,
bool TailFolded) const;
/// @}
/// \name Scalar Target Information
......@@ -1251,6 +1256,8 @@ public:
preferPredicateOverEpilogue(Loop *L, LoopInfo *LI, ScalarEvolution &SE,
AssumptionCache &AC, TargetLibraryInfo *TLI,
DominatorTree *DT, const LoopAccessInfo *LAI) = 0;
virtual bool emitGetActiveLaneMask(Loop *L, LoopInfo *LI, ScalarEvolution &SE,
bool TailFolded) = 0;
virtual bool isLegalAddImmediate(int64_t Imm) = 0;
virtual bool isLegalICmpImmediate(int64_t Imm) = 0;
virtual bool isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV,
......@@ -1530,6 +1537,10 @@ public:
const LoopAccessInfo *LAI) override {
return Impl.preferPredicateOverEpilogue(L, LI, SE, AC, TLI, DT, LAI);
}
bool emitGetActiveLaneMask(Loop *L, LoopInfo *LI, ScalarEvolution &SE,
bool TailFolded) override {
return Impl.emitGetActiveLaneMask(L, LI, SE, TailFolded);
}
bool isLegalAddImmediate(int64_t Imm) override {
return Impl.isLegalAddImmediate(Imm);
}
......
......@@ -140,6 +140,11 @@ public:
return false;
}
bool emitGetActiveLaneMask(Loop *L, LoopInfo *LI, ScalarEvolution &SE,
bool TailFold) const {
return false;
}
void getUnrollingPreferences(Loop *, ScalarEvolution &,
TTI::UnrollingPreferences &) {}
......
......@@ -462,6 +462,11 @@ public:
return BaseT::preferPredicateOverEpilogue(L, LI, SE, AC, TLI, DT, LAI);
}
bool emitGetActiveLaneMask(Loop *L, LoopInfo *LI, ScalarEvolution &SE,
bool TailFold) {
return BaseT::emitGetActiveLaneMask(L, LI, SE, TailFold);
}
int getInstructionLatency(const Instruction *I) {
if (isa<LoadInst>(I))
return getST()->getSchedModel().DefaultLoadLatency;
......
......@@ -312,6 +312,11 @@ bool TargetTransformInfo::preferPredicateOverEpilogue(
return TTIImpl->preferPredicateOverEpilogue(L, LI, SE, AC, TLI, DT, LAI);
}
bool TargetTransformInfo::emitGetActiveLaneMask(Loop *L, LoopInfo *LI,
ScalarEvolution &SE, bool TailFolded) const {
return TTIImpl->emitGetActiveLaneMask(L, LI, SE, TailFolded);
}
void TargetTransformInfo::getUnrollingPreferences(
Loop *L, ScalarEvolution &SE, UnrollingPreferences &UP) const {
return TTIImpl->getUnrollingPreferences(L, SE, UP);
......
......@@ -1393,7 +1393,14 @@ bool ARMTTIImpl::preferPredicateOverEpilogue(Loop *L, LoopInfo *LI,
return canTailPredicateLoop(L, LI, SE, DL, LAI);
}
bool ARMTTIImpl::emitGetActiveLaneMask(Loop *L, LoopInfo *LI,
ScalarEvolution &SE, bool TailFolded) const {
// TODO: if this loop is tail-folded, we want to emit the
// llvm.get.active.lane.mask intrinsic so that this can be picked up in the
// MVETailPredication pass that needs to know the number of elements
// processed by this vector loop.
return false;
}
void ARMTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
TTI::UnrollingPreferences &UP) {
// Only currently enable these preferences for M-Class cores.
......
......@@ -250,6 +250,9 @@ public:
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
TTI::UnrollingPreferences &UP);
bool emitGetActiveLaneMask(Loop *L, LoopInfo *LI, ScalarEvolution &SE,
bool TailFolded) const;
bool shouldBuildLookupTablesForConstant(Constant *C) const {
// In the ROPI and RWPI relocation models we can't have pointers to global
// variables or functions in constant data, so don't convert switches to
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment