Skip to content

Commit a37e2d5

Browse files
committed
Reassociate and fixup typos
1 parent 640f3eb commit a37e2d5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -451,15 +451,15 @@ struct BinaryOp_match {
451451
const MachineInstr *TmpMI;
452452
if (mi_match(Op, MRI, m_MInstr(TmpMI))) {
453453
if (TmpMI->getOpcode() == Opcode && TmpMI->getNumOperands() == 3) {
454-
if (!(L.match(MRI, TmpMI->getOperand(1).getReg()) &&
455-
R.match(MRI, TmpMI->getOperand(2).getReg())) &&
454+
if ((!L.match(MRI, TmpMI->getOperand(1).getReg()) ||
455+
!R.match(MRI, TmpMI->getOperand(2).getReg())) &&
456456
// NOTE: When trying the alternative operand ordering
457457
// with a commutative operation, it is imperative to always run
458458
// the LHS sub-pattern (i.e. `L`) before the RHS sub-pattern
459-
// (i.e. `R`). Otherwsie, m_DeferredReg/Type will not work as
459+
// (i.e. `R`). Otherwise, m_DeferredReg/Type will not work as
460460
// expected.
461-
!(Commutable && (L.match(MRI, TmpMI->getOperand(2).getReg()) &&
462-
R.match(MRI, TmpMI->getOperand(1).getReg()))))
461+
(!Commutable || !L.match(MRI, TmpMI->getOperand(2).getReg()) ||
462+
!R.match(MRI, TmpMI->getOperand(1).getReg())))
463463
return false;
464464
return (TmpMI->getFlags() & Flags) == Flags;
465465
}
@@ -488,7 +488,7 @@ struct BinaryOpc_match {
488488
// NOTE: When trying the alternative operand ordering
489489
// with a commutative operation, it is imperative to always run
490490
// the LHS sub-pattern (i.e. `L`) before the RHS sub-pattern
491-
// (i.e. `R`). Otherwsie, m_DeferredReg/Type will not work as
491+
// (i.e. `R`). Otherwise, m_DeferredReg/Type will not work as
492492
// expected.
493493
(Commutable && (L.match(MRI, TmpMI->getOperand(2).getReg()) &&
494494
R.match(MRI, TmpMI->getOperand(1).getReg())));
@@ -754,7 +754,7 @@ struct CompareOp_match {
754754
// NOTE: When trying the alternative operand ordering
755755
// with a commutative operation, it is imperative to always run
756756
// the LHS sub-pattern (i.e. `L`) before the RHS sub-pattern
757-
// (i.e. `R`). Otherwsie, m_DeferredReg/Type will not work as expected.
757+
// (i.e. `R`). Otherwise, m_DeferredReg/Type will not work as expected.
758758
if (Commutable && L.match(MRI, RHS) && R.match(MRI, LHS) &&
759759
P.match(MRI, CmpInst::getSwappedPredicate(TmpPred)))
760760
return true;

0 commit comments

Comments
 (0)