diff options
author | Anna Thomas <anna@azul.com> | 2023-03-08 17:32:50 -0500 |
---|---|---|
committer | Anna Thomas <anna@azul.com> | 2023-03-21 12:08:25 -0400 |
commit | 4277d932ef180090f314f7eb7f47d63e76881d30 (patch) | |
tree | f079b2736e261426f9540bd9a3c5ccc9eef64405 /llvm/lib/Analysis/Loads.cpp | |
parent | 586ad89638dd1282a41780a3c369e1bd881a7f42 (diff) | |
download | llvm-4277d932ef180090f314f7eb7f47d63e76881d30.zip llvm-4277d932ef180090f314f7eb7f47d63e76881d30.tar.gz llvm-4277d932ef180090f314f7eb7f47d63e76881d30.tar.bz2 |
[LV] Use speculatability within entire loop to avoid strided load predication
Use existing functionality for identifying total access size by strided
loads. If we can speculate the load across all vector iterations, we can
avoid predication for these strided loads (or masked gathers in
architectures which support it).
Differential Revision: https://reviews.llvm.org/D145616
Diffstat (limited to 'llvm/lib/Analysis/Loads.cpp')
-rw-r--r-- | llvm/lib/Analysis/Loads.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/Loads.cpp b/llvm/lib/Analysis/Loads.cpp index 48e435a..90be40da8 100644 --- a/llvm/lib/Analysis/Loads.cpp +++ b/llvm/lib/Analysis/Loads.cpp @@ -286,15 +286,22 @@ bool llvm::isDereferenceableAndAlignedInLoop(LoadInst *LI, Loop *L, auto* Step = dyn_cast<SCEVConstant>(AddRec->getStepRecurrence(SE)); if (!Step) return false; - // TODO: generalize to access patterns which have gaps - if (Step->getAPInt() != EltSize) - return false; auto TC = SE.getSmallConstantMaxTripCount(L); if (!TC) return false; - const APInt AccessSize = TC * EltSize; + // TODO: Handle overlapping accesses. + // We should be computing AccessSize as (TC - 1) * Step + EltSize. + if (EltSize.sgt(Step->getAPInt())) + return false; + + // Compute the total access size for access patterns with unit stride and + // patterns with gaps. For patterns with unit stride, Step and EltSize are the + // same. + // For patterns with gaps (i.e. non unit stride), we are + // accessing EltSize bytes at every Step. + const APInt AccessSize = TC * Step->getAPInt(); auto *StartS = dyn_cast<SCEVUnknown>(AddRec->getStart()); if (!StartS) |