// If `V` is of the form `A + Constant` then `-1 - V` can be folded into
// `(-1 - Constant) - A` if we are willing to invert all of the uses.
- if (BinaryOperator *BO = dyn_cast<BinaryOperator>(V))
- if (BO->getOpcode() == Instruction::Add ||
- BO->getOpcode() == Instruction::Sub)
- if (match(BO, PatternMatch::m_c_BinOp(PatternMatch::m_Value(),
- PatternMatch::m_ImmConstant())))
- return WillInvertAllUses;
+ if (match(V, m_Add(PatternMatch::m_Value(), PatternMatch::m_ImmConstant())))
+ return WillInvertAllUses;
+
+ // If `V` is of the form `Constant - A` then `-1 - V` can be folded into
+ // `A + (-1 - Constant)` if we are willing to invert all of the uses.
+ if (match(V, m_Sub(PatternMatch::m_ImmConstant(), PatternMatch::m_Value())))
+ return WillInvertAllUses;
// Selects with invertible operands are freely invertible
if (match(V,