[TRE] Simplify canTRE() a bit using all_of(). NFCI.

This has a ~11 years old FIXME, which may not be true today.
We might consider removing this code altogether.

llvm-svn: 308319
This commit is contained in:
Davide Italiano 2017-07-18 15:42:59 +00:00
parent 4dfa732750
commit 6da7db31df
1 changed files with 5 additions and 10 deletions

View File

@ -68,6 +68,7 @@
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
@ -90,16 +91,10 @@ STATISTIC(NumAccumAdded, "Number of accumulators introduced");
/// If it contains any dynamic allocas, returns false.
static bool canTRE(Function &F) {
// Because of PR962, we don't TRE dynamic allocas.
for (auto &BB : F) {
for (auto &I : BB) {
if (AllocaInst *AI = dyn_cast<AllocaInst>(&I)) {
if (!AI->isStaticAlloca())
return false;
}
}
}
return true;
return llvm::all_of(instructions(F), [](Instruction &I) {
auto *AI = dyn_cast<AllocaInst>(&I);
return !AI || AI->isStaticAlloca();
});
}
namespace {