[llvm] r374744 - [NewGVN] Use m_Br to simplify code a bit. (NFC)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 13 16:34:13 PDT 2019
Author: fhahn
Date: Sun Oct 13 16:34:13 2019
New Revision: 374744
URL: http://llvm.org/viewvc/llvm-project?rev=374744&view=rev
Log:
[NewGVN] Use m_Br to simplify code a bit. (NFC)
Modified:
llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp?rev=374744&r1=374743&r2=374744&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp Sun Oct 13 16:34:13 2019
@@ -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"
@@ -122,6 +123,7 @@
using namespace llvm;
using namespace llvm::GVNExpression;
using namespace llvm::VNCoercion;
+using namespace llvm::PatternMatch;
#define DEBUG_TYPE "newgvn"
@@ -2464,9 +2466,9 @@ Value *NewGVN::findConditionEquivalence(
// 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)) {
@@ -2479,8 +2481,6 @@ void NewGVN::processOutgoingEdges(Instru
}
}
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
More information about the llvm-commits
mailing list