Skip to content

Commit

Permalink
[NewGVN] Use m_Br to simplify code a bit. (NFC)
Browse files Browse the repository at this point in the history
llvm-svn: 374744
  • Loading branch information
fhahn committed Oct 13, 2019
1 parent e4300c3 commit df4fd31
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions llvm/lib/Transforms/Scalar/NewGVN.cpp
Expand Up @@ -89,6 +89,7 @@
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Use.h"
#include "llvm/IR/User.h"
Expand Down Expand Up @@ -122,6 +123,7 @@
using namespace llvm;
using namespace llvm::GVNExpression;
using namespace llvm::VNCoercion;
using namespace llvm::PatternMatch;

#define DEBUG_TYPE "newgvn"

Expand Down Expand Up @@ -2464,9 +2466,9 @@ Value *NewGVN::findConditionEquivalence(Value *Cond) const {
// Process the outgoing edges of a block for reachability.
void NewGVN::processOutgoingEdges(Instruction *TI, BasicBlock *B) {
// Evaluate reachability of terminator instruction.
BranchInst *BR;
if ((BR = dyn_cast<BranchInst>(TI)) && BR->isConditional()) {
Value *Cond = BR->getCondition();
Value *Cond;
BasicBlock *TrueSucc, *FalseSucc;
if (match(TI, m_Br(m_Value(Cond), TrueSucc, FalseSucc))) {
Value *CondEvaluated = findConditionEquivalence(Cond);
if (!CondEvaluated) {
if (auto *I = dyn_cast<Instruction>(Cond)) {
Expand All @@ -2479,8 +2481,6 @@ void NewGVN::processOutgoingEdges(Instruction *TI, BasicBlock *B) {
}
}
ConstantInt *CI;
BasicBlock *TrueSucc = BR->getSuccessor(0);
BasicBlock *FalseSucc = BR->getSuccessor(1);
if (CondEvaluated && (CI = dyn_cast<ConstantInt>(CondEvaluated))) {
if (CI->isOne()) {
LLVM_DEBUG(dbgs() << "Condition for Terminator " << *TI
Expand Down

0 comments on commit df4fd31

Please sign in to comment.