[PATCH] D108750: [PowerPC] common chains to reuse offsets to reduce register pressure
Jinsong Ji via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 21 08:39:08 PDT 2021
jsji added inline comments.
================
Comment at: llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp:500
+ const SCEV *Diff = SE->getMinusSCEV(LSCEV, B.BaseSCEV);
+ if (isValidChainCommoningDiff(Diff)) {
+ B.Elements.push_back(BucketElement(Diff, MemI));
----------------
jsji wrote:
> Can we also abstract this check so that we can also reuse `addOneCandidate` to do this.
>
> Something like:
>
> ```
> for (auto &B : Buckets) {
> const SCEV *Diff = SE->getMinusSCEV(LSCEV, B.BaseSCEV);
> if ( const auto *Diff = isValidDiff(Diff, LSCEV, B.BaseSCEV)) {
> B.Elements.push_back(BucketElement(Diff, MemI));
> FoundBucket = true;
> break;
> }
> }
> ```
>
> then we use `isValidConstantDiff` for others, but `isValidChainCommoningDiff` for this.
>
> ```
> isValidConstantDiff(Diff, LSCEV, B.BaseSCEV) ={
> return dyn_cast<SCEVConstant>(Diff)
> }
>
> isValidChainCommoningDiff(Diff, LSCEV, B.BaseSCEV) ={
>
> assert(LSCEV && "Invalid SCEV for Ptr value.");
>
> // Don't mess up previous dform prepare.
> if (isa<SCEVConstant>(LSCEV))
> return null_ptr;
>
> // A single integer type offset.
> if (isa<SCEVUnknown>(LSCEV) && LSCEV->getType()->isIntegerTy())
> return Diff;
>
> const SCEVNAryExpr *ASCEV = dyn_cast<SCEVNAryExpr>(LSCEV);
> if (!ASCEV)
> return null_ptr;
>
> for (const SCEV *Op : ASCEV->operands())
> if (!Op->getType()->isIntegerTy())
> return null_ptr;
>
> return Diff;
>
>
> }
>
>
> ```
```
isValidChainCommoningDiff(Diff, LSCEV, B.BaseSCEV) ={
assert(LSCEV && "Invalid SCEV for Ptr value.");
if (cast<SCEVAddRecExpr>(B.BaseSCEV)->getStepRecurrence(*SE) !=
cast<SCEVAddRecExpr>(LSCEV)->getStepRecurrence(*SE))
return null_ptr;
// Don't mess up previous dform prepare.
if (isa<SCEVConstant>(LSCEV))
return null_ptr;
// A single integer type offset.
if (isa<SCEVUnknown>(LSCEV) && LSCEV->getType()->isIntegerTy())
return Diff;
const SCEVNAryExpr *ASCEV = dyn_cast<SCEVNAryExpr>(LSCEV);
if (!ASCEV)
return null_ptr;
for (const SCEV *Op : ASCEV->operands())
if (!Op->getType()->isIntegerTy())
return null_ptr;
return Diff;
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D108750/new/
https://reviews.llvm.org/D108750
More information about the llvm-commits
mailing list