mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-02 07:11:49 +00:00
[LoopAccesses] Change debug messages from LV to LAA
Also add pass name as an argument to VectorizationReport::emitAnalysis. This is part of the patchset that converts LoopAccessAnalysis into an actual analysis pass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229628 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
47985fb7cd
commit
ce5c5c0301
@ -55,11 +55,13 @@ public:
|
||||
std::string &str() { return Message; }
|
||||
operator Twine() { return Message; }
|
||||
|
||||
/// \brief Emit an analysis note with the debug location from the instruction
|
||||
/// in \p Message if available. Otherwise use the location of \p TheLoop.
|
||||
/// \brief Emit an analysis note for \p PassName with the debug location from
|
||||
/// the instruction in \p Message if available. Otherwise use the location of
|
||||
/// \p TheLoop.
|
||||
static void emitAnalysis(VectorizationReport &Message,
|
||||
const Function *TheFunction,
|
||||
const Loop *TheLoop);
|
||||
const Loop *TheLoop,
|
||||
const char *PassName);
|
||||
};
|
||||
|
||||
/// \brief Collection of parameters shared beetween the Loop Vectorizer and the
|
||||
|
@ -23,15 +23,16 @@
|
||||
#include "llvm/Transforms/Utils/VectorUtils.h"
|
||||
using namespace llvm;
|
||||
|
||||
#define DEBUG_TYPE "loop-vectorize"
|
||||
#define DEBUG_TYPE "loop-accesses"
|
||||
|
||||
void VectorizationReport::emitAnalysis(VectorizationReport &Message,
|
||||
const Function *TheFunction,
|
||||
const Loop *TheLoop) {
|
||||
const Loop *TheLoop,
|
||||
const char *PassName) {
|
||||
DebugLoc DL = TheLoop->getStartLoc();
|
||||
if (Instruction *I = Message.getInstr())
|
||||
DL = I->getDebugLoc();
|
||||
emitOptimizationRemarkAnalysis(TheFunction->getContext(), DEBUG_TYPE,
|
||||
emitOptimizationRemarkAnalysis(TheFunction->getContext(), PassName,
|
||||
*TheFunction, DL, Message.str());
|
||||
}
|
||||
|
||||
@ -64,7 +65,7 @@ const SCEV *llvm::replaceSymbolicStrideSCEV(ScalarEvolution *SE,
|
||||
|
||||
const SCEV *ByOne =
|
||||
SCEVParameterRewriter::rewrite(OrigSCEV, *SE, RewriteMap, true);
|
||||
DEBUG(dbgs() << "LV: Replacing SCEV: " << *OrigSCEV << " by: " << *ByOne
|
||||
DEBUG(dbgs() << "LAA: Replacing SCEV: " << *OrigSCEV << " by: " << *ByOne
|
||||
<< "\n");
|
||||
return ByOne;
|
||||
}
|
||||
@ -247,7 +248,7 @@ bool AccessAnalysis::canCheckPtrAtRT(
|
||||
|
||||
RtCheck.insert(SE, TheLoop, Ptr, IsWrite, DepId, ASId, StridesMap);
|
||||
|
||||
DEBUG(dbgs() << "LV: Found a runtime check ptr:" << *Ptr << '\n');
|
||||
DEBUG(dbgs() << "LAA: Found a runtime check ptr:" << *Ptr << '\n');
|
||||
} else {
|
||||
CanDoRT = false;
|
||||
}
|
||||
@ -284,7 +285,7 @@ bool AccessAnalysis::canCheckPtrAtRT(
|
||||
unsigned ASi = PtrI->getType()->getPointerAddressSpace();
|
||||
unsigned ASj = PtrJ->getType()->getPointerAddressSpace();
|
||||
if (ASi != ASj) {
|
||||
DEBUG(dbgs() << "LV: Runtime check would require comparison between"
|
||||
DEBUG(dbgs() << "LAA: Runtime check would require comparison between"
|
||||
" different address spaces\n");
|
||||
return false;
|
||||
}
|
||||
@ -299,9 +300,9 @@ void AccessAnalysis::processMemAccesses() {
|
||||
// process read-only pointers. This allows us to skip dependence tests for
|
||||
// read-only pointers.
|
||||
|
||||
DEBUG(dbgs() << "LV: Processing memory accesses...\n");
|
||||
DEBUG(dbgs() << "LAA: Processing memory accesses...\n");
|
||||
DEBUG(dbgs() << " AST: "; AST.dump());
|
||||
DEBUG(dbgs() << "LV: Accesses:\n");
|
||||
DEBUG(dbgs() << "LAA: Accesses:\n");
|
||||
DEBUG({
|
||||
for (auto A : Accesses)
|
||||
dbgs() << "\t" << *A.getPointer() << " (" <<
|
||||
@ -532,8 +533,8 @@ static int isStridedPtr(ScalarEvolution *SE, const DataLayout *DL, Value *Ptr,
|
||||
// Make sure that the pointer does not point to aggregate types.
|
||||
const PointerType *PtrTy = cast<PointerType>(Ty);
|
||||
if (PtrTy->getElementType()->isAggregateType()) {
|
||||
DEBUG(dbgs() << "LV: Bad stride - Not a pointer to a scalar type" << *Ptr <<
|
||||
"\n");
|
||||
DEBUG(dbgs() << "LAA: Bad stride - Not a pointer to a scalar type"
|
||||
<< *Ptr << "\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -541,14 +542,14 @@ static int isStridedPtr(ScalarEvolution *SE, const DataLayout *DL, Value *Ptr,
|
||||
|
||||
const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(PtrScev);
|
||||
if (!AR) {
|
||||
DEBUG(dbgs() << "LV: Bad stride - Not an AddRecExpr pointer "
|
||||
DEBUG(dbgs() << "LAA: Bad stride - Not an AddRecExpr pointer "
|
||||
<< *Ptr << " SCEV: " << *PtrScev << "\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// The accesss function must stride over the innermost loop.
|
||||
if (Lp != AR->getLoop()) {
|
||||
DEBUG(dbgs() << "LV: Bad stride - Not striding over innermost loop " <<
|
||||
DEBUG(dbgs() << "LAA: Bad stride - Not striding over innermost loop " <<
|
||||
*Ptr << " SCEV: " << *PtrScev << "\n");
|
||||
}
|
||||
|
||||
@ -563,7 +564,7 @@ static int isStridedPtr(ScalarEvolution *SE, const DataLayout *DL, Value *Ptr,
|
||||
bool IsNoWrapAddRec = AR->getNoWrapFlags(SCEV::NoWrapMask);
|
||||
bool IsInAddressSpaceZero = PtrTy->getAddressSpace() == 0;
|
||||
if (!IsNoWrapAddRec && !IsInBoundsGEP && !IsInAddressSpaceZero) {
|
||||
DEBUG(dbgs() << "LV: Bad stride - Pointer may wrap in the address space "
|
||||
DEBUG(dbgs() << "LAA: Bad stride - Pointer may wrap in the address space "
|
||||
<< *Ptr << " SCEV: " << *PtrScev << "\n");
|
||||
return 0;
|
||||
}
|
||||
@ -574,7 +575,7 @@ static int isStridedPtr(ScalarEvolution *SE, const DataLayout *DL, Value *Ptr,
|
||||
// Calculate the pointer stride and check if it is consecutive.
|
||||
const SCEVConstant *C = dyn_cast<SCEVConstant>(Step);
|
||||
if (!C) {
|
||||
DEBUG(dbgs() << "LV: Bad stride - Not a constant strided " << *Ptr <<
|
||||
DEBUG(dbgs() << "LAA: Bad stride - Not a constant strided " << *Ptr <<
|
||||
" SCEV: " << *PtrScev << "\n");
|
||||
return 0;
|
||||
}
|
||||
@ -631,7 +632,7 @@ bool MemoryDepChecker::couldPreventStoreLoadForward(unsigned Distance,
|
||||
}
|
||||
|
||||
if (MaxVFWithoutSLForwardIssues< 2*TypeByteSize) {
|
||||
DEBUG(dbgs() << "LV: Distance " << Distance <<
|
||||
DEBUG(dbgs() << "LAA: Distance " << Distance <<
|
||||
" that could cause a store-load forwarding conflict\n");
|
||||
return true;
|
||||
}
|
||||
@ -685,9 +686,9 @@ bool MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
|
||||
|
||||
const SCEV *Dist = SE->getMinusSCEV(Sink, Src);
|
||||
|
||||
DEBUG(dbgs() << "LV: Src Scev: " << *Src << "Sink Scev: " << *Sink
|
||||
DEBUG(dbgs() << "LAA: Src Scev: " << *Src << "Sink Scev: " << *Sink
|
||||
<< "(Induction step: " << StrideAPtr << ")\n");
|
||||
DEBUG(dbgs() << "LV: Distance for " << *InstMap[AIdx] << " to "
|
||||
DEBUG(dbgs() << "LAA: Distance for " << *InstMap[AIdx] << " to "
|
||||
<< *InstMap[BIdx] << ": " << *Dist << "\n");
|
||||
|
||||
// Need consecutive accesses. We don't want to vectorize
|
||||
@ -700,7 +701,7 @@ bool MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
|
||||
|
||||
const SCEVConstant *C = dyn_cast<SCEVConstant>(Dist);
|
||||
if (!C) {
|
||||
DEBUG(dbgs() << "LV: Dependence because of non-constant distance\n");
|
||||
DEBUG(dbgs() << "LAA: Dependence because of non-constant distance\n");
|
||||
ShouldRetryWithRuntimeCheck = true;
|
||||
return true;
|
||||
}
|
||||
@ -718,7 +719,7 @@ bool MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
|
||||
ATy != BTy))
|
||||
return true;
|
||||
|
||||
DEBUG(dbgs() << "LV: Dependence is negative: NoDep\n");
|
||||
DEBUG(dbgs() << "LAA: Dependence is negative: NoDep\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -727,7 +728,7 @@ bool MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
|
||||
if (Val == 0) {
|
||||
if (ATy == BTy)
|
||||
return false;
|
||||
DEBUG(dbgs() << "LV: Zero dependence difference but different types\n");
|
||||
DEBUG(dbgs() << "LAA: Zero dependence difference but different types\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -736,7 +737,7 @@ bool MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
|
||||
// Positive distance bigger than max vectorization factor.
|
||||
if (ATy != BTy) {
|
||||
DEBUG(dbgs() <<
|
||||
"LV: ReadWrite-Write positive dependency with different types\n");
|
||||
"LAA: ReadWrite-Write positive dependency with different types\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -754,7 +755,7 @@ bool MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
|
||||
if (Distance < 2*TypeByteSize ||
|
||||
2*TypeByteSize > MaxSafeDepDistBytes ||
|
||||
Distance < TypeByteSize * ForcedUnroll * ForcedFactor) {
|
||||
DEBUG(dbgs() << "LV: Failure because of Positive distance "
|
||||
DEBUG(dbgs() << "LAA: Failure because of Positive distance "
|
||||
<< Val.getSExtValue() << '\n');
|
||||
return true;
|
||||
}
|
||||
@ -767,7 +768,7 @@ bool MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
|
||||
couldPreventStoreLoadForward(Distance, TypeByteSize))
|
||||
return true;
|
||||
|
||||
DEBUG(dbgs() << "LV: Positive distance " << Val.getSExtValue() <<
|
||||
DEBUG(dbgs() << "LAA: Positive distance " << Val.getSExtValue() <<
|
||||
" with max VF = " << MaxSafeDepDistBytes / TypeByteSize << '\n');
|
||||
|
||||
return false;
|
||||
@ -854,7 +855,7 @@ void LoopAccessInfo::analyzeLoop(ValueToValueMap &Strides) {
|
||||
if (!Ld || (!Ld->isSimple() && !IsAnnotatedParallel)) {
|
||||
emitAnalysis(VectorizationReport(Ld)
|
||||
<< "read with atomic ordering or volatile read");
|
||||
DEBUG(dbgs() << "LV: Found a non-simple load.\n");
|
||||
DEBUG(dbgs() << "LAA: Found a non-simple load.\n");
|
||||
CanVecMem = false;
|
||||
return;
|
||||
}
|
||||
@ -876,7 +877,7 @@ void LoopAccessInfo::analyzeLoop(ValueToValueMap &Strides) {
|
||||
if (!St->isSimple() && !IsAnnotatedParallel) {
|
||||
emitAnalysis(VectorizationReport(St)
|
||||
<< "write with atomic ordering or volatile write");
|
||||
DEBUG(dbgs() << "LV: Found a non-simple store.\n");
|
||||
DEBUG(dbgs() << "LAA: Found a non-simple store.\n");
|
||||
CanVecMem = false;
|
||||
return;
|
||||
}
|
||||
@ -893,7 +894,7 @@ void LoopAccessInfo::analyzeLoop(ValueToValueMap &Strides) {
|
||||
// Check if we see any stores. If there are no stores, then we don't
|
||||
// care if the pointers are *restrict*.
|
||||
if (!Stores.size()) {
|
||||
DEBUG(dbgs() << "LV: Found a read-only loop!\n");
|
||||
DEBUG(dbgs() << "LAA: Found a read-only loop!\n");
|
||||
CanVecMem = true;
|
||||
return;
|
||||
}
|
||||
@ -917,7 +918,7 @@ void LoopAccessInfo::analyzeLoop(ValueToValueMap &Strides) {
|
||||
emitAnalysis(
|
||||
VectorizationReport(ST)
|
||||
<< "write to a loop invariant address could not be vectorized");
|
||||
DEBUG(dbgs() << "LV: We don't allow storing to uniform addresses\n");
|
||||
DEBUG(dbgs() << "LAA: We don't allow storing to uniform addresses\n");
|
||||
CanVecMem = false;
|
||||
return;
|
||||
}
|
||||
@ -940,7 +941,7 @@ void LoopAccessInfo::analyzeLoop(ValueToValueMap &Strides) {
|
||||
|
||||
if (IsAnnotatedParallel) {
|
||||
DEBUG(dbgs()
|
||||
<< "LV: A loop annotated parallel, ignore memory dependency "
|
||||
<< "LAA: A loop annotated parallel, ignore memory dependency "
|
||||
<< "checks.\n");
|
||||
CanVecMem = true;
|
||||
return;
|
||||
@ -977,7 +978,7 @@ void LoopAccessInfo::analyzeLoop(ValueToValueMap &Strides) {
|
||||
// If we write (or read-write) to a single destination and there are no
|
||||
// other reads in this loop then is it safe to vectorize.
|
||||
if (NumReadWrites == 1 && NumReads == 0) {
|
||||
DEBUG(dbgs() << "LV: Found a write-only loop!\n");
|
||||
DEBUG(dbgs() << "LAA: Found a write-only loop!\n");
|
||||
CanVecMem = true;
|
||||
return;
|
||||
}
|
||||
@ -995,7 +996,7 @@ void LoopAccessInfo::analyzeLoop(ValueToValueMap &Strides) {
|
||||
CanDoRT = Accesses.canCheckPtrAtRT(PtrRtCheck, NumComparisons, SE, TheLoop,
|
||||
Strides);
|
||||
|
||||
DEBUG(dbgs() << "LV: We need to do " << NumComparisons <<
|
||||
DEBUG(dbgs() << "LAA: We need to do " << NumComparisons <<
|
||||
" pointer comparisons.\n");
|
||||
|
||||
// If we only have one set of dependences to check pointers among we don't
|
||||
@ -1012,12 +1013,12 @@ void LoopAccessInfo::analyzeLoop(ValueToValueMap &Strides) {
|
||||
}
|
||||
|
||||
if (CanDoRT) {
|
||||
DEBUG(dbgs() << "LV: We can perform a memory runtime check if needed.\n");
|
||||
DEBUG(dbgs() << "LAA: We can perform a memory runtime check if needed.\n");
|
||||
}
|
||||
|
||||
if (NeedRTCheck && !CanDoRT) {
|
||||
emitAnalysis(VectorizationReport() << "cannot identify array bounds");
|
||||
DEBUG(dbgs() << "LV: We can't vectorize because we can't find " <<
|
||||
DEBUG(dbgs() << "LAA: We can't vectorize because we can't find " <<
|
||||
"the array bounds.\n");
|
||||
PtrRtCheck.reset();
|
||||
CanVecMem = false;
|
||||
@ -1028,13 +1029,13 @@ void LoopAccessInfo::analyzeLoop(ValueToValueMap &Strides) {
|
||||
|
||||
CanVecMem = true;
|
||||
if (Accesses.isDependencyCheckNeeded()) {
|
||||
DEBUG(dbgs() << "LV: Checking memory dependencies\n");
|
||||
DEBUG(dbgs() << "LAA: Checking memory dependencies\n");
|
||||
CanVecMem = DepChecker.areDepsSafe(
|
||||
DependentAccesses, Accesses.getDependenciesToCheck(), Strides);
|
||||
MaxSafeDepDistBytes = DepChecker.getMaxSafeDepDistBytes();
|
||||
|
||||
if (!CanVecMem && DepChecker.shouldRetryWithRuntimeCheck()) {
|
||||
DEBUG(dbgs() << "LV: Retrying with memory checks\n");
|
||||
DEBUG(dbgs() << "LAA: Retrying with memory checks\n");
|
||||
NeedRTCheck = true;
|
||||
|
||||
// Clear the dependency checks. We assume they are not needed.
|
||||
@ -1057,7 +1058,7 @@ void LoopAccessInfo::analyzeLoop(ValueToValueMap &Strides) {
|
||||
<< NumComparisons << " exceeds limit of "
|
||||
<< VectorizerParams::RuntimeMemoryCheckThreshold
|
||||
<< " dependent memory operations checked at runtime");
|
||||
DEBUG(dbgs() << "LV: Can't vectorize with memory checks\n");
|
||||
DEBUG(dbgs() << "LAA: Can't vectorize with memory checks\n");
|
||||
PtrRtCheck.reset();
|
||||
CanVecMem = false;
|
||||
return;
|
||||
@ -1071,7 +1072,7 @@ void LoopAccessInfo::analyzeLoop(ValueToValueMap &Strides) {
|
||||
emitAnalysis(VectorizationReport() <<
|
||||
"unsafe dependent memory operations in loop");
|
||||
|
||||
DEBUG(dbgs() << "LV: We" << (NeedRTCheck ? "" : " don't") <<
|
||||
DEBUG(dbgs() << "LAA: We" << (NeedRTCheck ? "" : " don't") <<
|
||||
" need a runtime memory check.\n");
|
||||
}
|
||||
|
||||
@ -1123,12 +1124,12 @@ LoopAccessInfo::addRuntimeCheck(Instruction *Loc) {
|
||||
const SCEV *Sc = SE->getSCEV(Ptr);
|
||||
|
||||
if (SE->isLoopInvariant(Sc, TheLoop)) {
|
||||
DEBUG(dbgs() << "LV: Adding RT check for a loop invariant ptr:" <<
|
||||
DEBUG(dbgs() << "LAA: Adding RT check for a loop invariant ptr:" <<
|
||||
*Ptr <<"\n");
|
||||
Starts.push_back(Ptr);
|
||||
Ends.push_back(Ptr);
|
||||
} else {
|
||||
DEBUG(dbgs() << "LV: Adding RT check for range:" << *Ptr << '\n');
|
||||
DEBUG(dbgs() << "LAA: Adding RT check for range:" << *Ptr << '\n');
|
||||
unsigned AS = Ptr->getType()->getPointerAddressSpace();
|
||||
|
||||
// Use this type for pointer arithmetic.
|
||||
|
@ -837,7 +837,7 @@ private:
|
||||
/// Report an analysis message to assist the user in diagnosing loops that are
|
||||
/// not vectorized.
|
||||
void emitAnalysis(VectorizationReport &Message) {
|
||||
VectorizationReport::emitAnalysis(Message, TheFunction, TheLoop);
|
||||
VectorizationReport::emitAnalysis(Message, TheFunction, TheLoop, LV_NAME);
|
||||
}
|
||||
|
||||
unsigned NumPredStores;
|
||||
@ -974,7 +974,7 @@ private:
|
||||
/// Report an analysis message to assist the user in diagnosing loops that are
|
||||
/// not vectorized.
|
||||
void emitAnalysis(VectorizationReport &Message) {
|
||||
VectorizationReport::emitAnalysis(Message, TheFunction, TheLoop);
|
||||
VectorizationReport::emitAnalysis(Message, TheFunction, TheLoop, LV_NAME);
|
||||
}
|
||||
|
||||
/// Values used only by @llvm.assume calls.
|
||||
|
Loading…
Reference in New Issue
Block a user