Navigation Menu

Skip to content

Commit

Permalink
[ScalarizeMaskedMemIntrin] NFC: Convert member functions to static
Browse files Browse the repository at this point in the history
This will make it easier to add new PM support once the pass is moved
into transforms (D92407).
  • Loading branch information
annamthomas committed Dec 3, 2020
1 parent cc8df90 commit f86ec1e
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions llvm/lib/CodeGen/ScalarizeMaskedMemIntrin.cpp
Expand Up @@ -61,14 +61,16 @@ class ScalarizeMaskedMemIntrin : public FunctionPass {
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequired<TargetTransformInfoWrapperPass>();
}

private:
bool optimizeBlock(BasicBlock &BB, bool &ModifiedDT);
bool optimizeCallInst(CallInst *CI, bool &ModifiedDT);
};

} // end anonymous namespace

static bool optimizeBlock(BasicBlock &BB, bool &ModifiedDT,
const TargetTransformInfo *TTI, const DataLayout *DL);
static bool optimizeCallInst(CallInst *CI, bool &ModifiedDT,
const TargetTransformInfo *TTI,
const DataLayout *DL);

char ScalarizeMaskedMemIntrin::ID = 0;

INITIALIZE_PASS(ScalarizeMaskedMemIntrin, DEBUG_TYPE,
Expand Down Expand Up @@ -834,7 +836,7 @@ bool ScalarizeMaskedMemIntrin::runOnFunction(Function &F) {
for (Function::iterator I = F.begin(); I != F.end();) {
BasicBlock *BB = &*I++;
bool ModifiedDTOnIteration = false;
MadeChange |= optimizeBlock(*BB, ModifiedDTOnIteration);
MadeChange |= optimizeBlock(*BB, ModifiedDTOnIteration, TTI, DL);

// Restart BB iteration if the dominator tree of the Function was changed
if (ModifiedDTOnIteration)
Expand All @@ -847,22 +849,25 @@ bool ScalarizeMaskedMemIntrin::runOnFunction(Function &F) {
return EverMadeChange;
}

bool ScalarizeMaskedMemIntrin::optimizeBlock(BasicBlock &BB, bool &ModifiedDT) {
static bool optimizeBlock(BasicBlock &BB, bool &ModifiedDT,
const TargetTransformInfo *TTI,
const DataLayout *DL) {
bool MadeChange = false;

BasicBlock::iterator CurInstIterator = BB.begin();
while (CurInstIterator != BB.end()) {
if (CallInst *CI = dyn_cast<CallInst>(&*CurInstIterator++))
MadeChange |= optimizeCallInst(CI, ModifiedDT);
MadeChange |= optimizeCallInst(CI, ModifiedDT, TTI, DL);
if (ModifiedDT)
return true;
}

return MadeChange;
}

bool ScalarizeMaskedMemIntrin::optimizeCallInst(CallInst *CI,
bool &ModifiedDT) {
static bool optimizeCallInst(CallInst *CI, bool &ModifiedDT,
const TargetTransformInfo *TTI,
const DataLayout *DL) {
IntrinsicInst *II = dyn_cast<IntrinsicInst>(CI);
if (II) {
// The scalarization code below does not work for scalable vectors.
Expand Down

0 comments on commit f86ec1e

Please sign in to comment.