@@ -3133,31 +3133,28 @@ Instruction *InstCombinerImpl::visitBranchInst(BranchInst &BI) {
3133
3133
return visitUnconditionalBranchInst (BI);
3134
3134
3135
3135
// Change br (not X), label True, label False to: br X, label False, True
3136
+ Value *Cond = BI.getCondition ();
3136
3137
Value *X = nullptr ;
3137
- if (match (&BI, m_Br (m_Not (m_Value (X)), m_BasicBlock (), m_BasicBlock ())) &&
3138
- !isa<Constant>(X)) {
3138
+ if (match (Cond, m_Not (m_Value (X))) && !isa<Constant>(X)) {
3139
3139
// Swap Destinations and condition...
3140
3140
BI.swapSuccessors ();
3141
3141
return replaceOperand (BI, 0 , X);
3142
3142
}
3143
3143
3144
3144
// If the condition is irrelevant, remove the use so that other
3145
3145
// transforms on the condition become more effective.
3146
- if (!isa<ConstantInt>(BI.getCondition ()) &&
3147
- BI.getSuccessor (0 ) == BI.getSuccessor (1 ))
3148
- return replaceOperand (
3149
- BI, 0 , ConstantInt::getFalse (BI.getCondition ()->getType ()));
3146
+ if (!isa<ConstantInt>(Cond) && BI.getSuccessor (0 ) == BI.getSuccessor (1 ))
3147
+ return replaceOperand (BI, 0 , ConstantInt::getFalse (Cond->getType ()));
3150
3148
3151
3149
// Canonicalize, for example, fcmp_one -> fcmp_oeq.
3152
3150
CmpInst::Predicate Pred;
3153
- if (match (&BI, m_Br (m_OneUse (m_FCmp (Pred, m_Value (), m_Value ())),
3154
- m_BasicBlock (), m_BasicBlock ())) &&
3151
+ if (match (Cond, m_OneUse (m_FCmp (Pred, m_Value (), m_Value ()))) &&
3155
3152
!isCanonicalPredicate (Pred)) {
3156
3153
// Swap destinations and condition.
3157
- CmpInst *Cond = cast<CmpInst>(BI. getCondition () );
3158
- Cond ->setPredicate (CmpInst::getInversePredicate (Pred));
3154
+ auto *Cmp = cast<CmpInst>(Cond );
3155
+ Cmp ->setPredicate (CmpInst::getInversePredicate (Pred));
3159
3156
BI.swapSuccessors ();
3160
- Worklist.push (Cond );
3157
+ Worklist.push (Cmp );
3161
3158
return &BI;
3162
3159
}
3163
3160
0 commit comments