mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 02:33:06 +01:00
Use AssumeInst in a few more places [nfc]
Follow up to a6d2a8d6f5. These were found by simply grepping for "::assume", and are the subset of that result which looked cleaner to me using the isa/dyn_cast patterns.
This commit is contained in:
parent
12a1cee9f5
commit
09ede8de1f
@ -202,9 +202,9 @@ void AssumptionCache::scanFunction() {
|
||||
// Go through all instructions in all blocks, add all calls to @llvm.assume
|
||||
// to this cache.
|
||||
for (BasicBlock &B : F)
|
||||
for (Instruction &II : B)
|
||||
if (match(&II, m_Intrinsic<Intrinsic::assume>()))
|
||||
AssumeHandles.push_back({&II, ExprResultIdx});
|
||||
for (Instruction &I : B)
|
||||
if (isa<AssumeInst>(&I))
|
||||
AssumeHandles.push_back({&I, ExprResultIdx});
|
||||
|
||||
// Mark the scan as complete.
|
||||
Scanned = true;
|
||||
|
@ -176,11 +176,7 @@ static void addIntrinsicToSummary(
|
||||
// Intrinsics that are assumed are relevant only to the devirtualization
|
||||
// pass, not the type test lowering pass.
|
||||
bool HasNonAssumeUses = llvm::any_of(CI->uses(), [](const Use &CIU) {
|
||||
auto *AssumeCI = dyn_cast<CallInst>(CIU.getUser());
|
||||
if (!AssumeCI)
|
||||
return true;
|
||||
Function *F = AssumeCI->getCalledFunction();
|
||||
return !F || F->getIntrinsicID() != Intrinsic::assume;
|
||||
return !isa<AssumeInst>(CIU.getUser());
|
||||
});
|
||||
if (HasNonAssumeUses)
|
||||
TypeTests.insert(Guid);
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "llvm/IR/Constants.h"
|
||||
#include "llvm/IR/Dominators.h"
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/IntrinsicInst.h"
|
||||
#include "llvm/IR/Intrinsics.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
|
||||
@ -80,13 +81,9 @@ void llvm::findDevirtualizableCallsForTypeTest(
|
||||
const Module *M = CI->getParent()->getParent()->getParent();
|
||||
|
||||
// Find llvm.assume intrinsics for this llvm.type.test call.
|
||||
for (const Use &CIU : CI->uses()) {
|
||||
if (auto *AssumeCI = dyn_cast<CallInst>(CIU.getUser())) {
|
||||
Function *F = AssumeCI->getCalledFunction();
|
||||
if (F && F->getIntrinsicID() == Intrinsic::assume)
|
||||
Assumes.push_back(AssumeCI);
|
||||
}
|
||||
}
|
||||
for (const Use &CIU : CI->uses())
|
||||
if (auto *Assume = dyn_cast<AssumeInst>(CIU.getUser()))
|
||||
Assumes.push_back(Assume);
|
||||
|
||||
// If we found any, search for virtual calls based on %p and add them to
|
||||
// DevirtCalls.
|
||||
|
@ -626,12 +626,10 @@ bool CodeGenPrepare::eliminateAssumptions(Function &F) {
|
||||
CurInstIterator = BB.begin();
|
||||
while (CurInstIterator != BB.end()) {
|
||||
Instruction *I = &*(CurInstIterator++);
|
||||
if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) {
|
||||
if (II->getIntrinsicID() != Intrinsic::assume)
|
||||
continue;
|
||||
if (auto *Assume = dyn_cast<AssumeInst>(I)) {
|
||||
MadeChange = true;
|
||||
Value *Operand = II->getOperand(0);
|
||||
II->eraseFromParent();
|
||||
Value *Operand = Assume->getOperand(0);
|
||||
Assume->eraseFromParent();
|
||||
|
||||
resetIteratorIfInvalidatedWhileCalling(&BB, [&]() {
|
||||
RecursivelyDeleteTriviallyDeadInstructions(Operand, TLInfo, nullptr);
|
||||
|
@ -107,9 +107,7 @@ MutableArrayRef<uint8_t> User::getDescriptor() {
|
||||
}
|
||||
|
||||
bool User::isDroppable() const {
|
||||
if (const auto *Intr = dyn_cast<IntrinsicInst>(this))
|
||||
return Intr->getIntrinsicID() == Intrinsic::assume;
|
||||
return false;
|
||||
return isa<AssumeInst>(this);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -205,8 +205,7 @@ void Value::dropDroppableUsesIn(User &Usr) {
|
||||
|
||||
void Value::dropDroppableUse(Use &U) {
|
||||
U.removeFromList();
|
||||
if (auto *Assume = dyn_cast<IntrinsicInst>(U.getUser())) {
|
||||
assert(Assume->getIntrinsicID() == Intrinsic::assume);
|
||||
if (auto *Assume = dyn_cast<AssumeInst>(U.getUser())) {
|
||||
unsigned OpNo = U.getOperandNo();
|
||||
if (OpNo == 0)
|
||||
U.set(ConstantInt::getTrue(Assume->getContext()));
|
||||
|
@ -1791,9 +1791,8 @@ bool LowerTypeTestsModule::lower() {
|
||||
auto *CI = cast<CallInst>((*UI++).getUser());
|
||||
// Find and erase llvm.assume intrinsics for this llvm.type.test call.
|
||||
for (auto CIU = CI->use_begin(), CIUE = CI->use_end(); CIU != CIUE;)
|
||||
if (auto *II = dyn_cast<IntrinsicInst>((*CIU++).getUser()))
|
||||
if (II->getIntrinsicID() == Intrinsic::assume)
|
||||
II->eraseFromParent();
|
||||
if (auto *Assume = dyn_cast<AssumeInst>((*CIU++).getUser()))
|
||||
Assume->eraseFromParent();
|
||||
CI->eraseFromParent();
|
||||
}
|
||||
|
||||
@ -2062,9 +2061,8 @@ bool LowerTypeTestsModule::lower() {
|
||||
// with the DropTypeTests flag set.
|
||||
bool OnlyAssumeUses = !CI->use_empty();
|
||||
for (const Use &CIU : CI->uses()) {
|
||||
if (auto *II = dyn_cast<IntrinsicInst>(CIU.getUser()))
|
||||
if (II->getIntrinsicID() == Intrinsic::assume)
|
||||
continue;
|
||||
if (isa<AssumeInst>(CIU.getUser()))
|
||||
continue;
|
||||
OnlyAssumeUses = false;
|
||||
break;
|
||||
}
|
||||
|
@ -3982,8 +3982,8 @@ static bool combineInstructionsOverFunction(
|
||||
F.getContext(), TargetFolder(DL),
|
||||
IRBuilderCallbackInserter([&Worklist, &AC](Instruction *I) {
|
||||
Worklist.add(I);
|
||||
if (match(I, m_Intrinsic<Intrinsic::assume>()))
|
||||
AC.registerAssumption(cast<AssumeInst>(I));
|
||||
if (auto *Assume = dyn_cast<AssumeInst>(I))
|
||||
AC.registerAssumption(Assume);
|
||||
}));
|
||||
|
||||
// Lower dbg.declare intrinsics otherwise their value may be clobbered
|
||||
|
@ -1219,9 +1219,8 @@ bool EarlyCSE::processNode(DomTreeNode *Node) {
|
||||
// they're marked as such to ensure preservation of control dependencies),
|
||||
// and this pass will not bother with its removal. However, we should mark
|
||||
// its condition as true for all dominated blocks.
|
||||
if (match(&Inst, m_Intrinsic<Intrinsic::assume>())) {
|
||||
auto *CondI =
|
||||
dyn_cast<Instruction>(cast<CallInst>(Inst).getArgOperand(0));
|
||||
if (auto *Assume = dyn_cast<AssumeInst>(&Inst)) {
|
||||
auto *CondI = dyn_cast<Instruction>(Assume->getArgOperand(0));
|
||||
if (CondI && SimpleValue::canHandle(CondI)) {
|
||||
LLVM_DEBUG(dbgs() << "EarlyCSE considering assumption: " << Inst
|
||||
<< '\n');
|
||||
|
@ -2529,8 +2529,9 @@ static bool FoldCondBranchOnPHI(BranchInst *BI, DomTreeUpdater *DTU,
|
||||
EdgeBB->getInstList().insert(InsertPt, N);
|
||||
|
||||
// Register the new instruction with the assumption cache if necessary.
|
||||
if (AC && match(N, m_Intrinsic<Intrinsic::assume>()))
|
||||
AC->registerAssumption(cast<AssumeInst>(N));
|
||||
if (auto *Assume = dyn_cast<AssumeInst>(N))
|
||||
if (AC)
|
||||
AC->registerAssumption(Assume);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user