Skip to content

Commit 463c9f0

Browse files
authored
InstCombine: Stop using m_c_BinOp for non-commutative ops (#172327)
The previous flow tried both m_BinOp and m_c_BinOp for noncommutative ops. Seems to have worked out OK though, since there are no test changes.
1 parent b6c0eef commit 463c9f0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,13 @@ static Instruction *foldSelectBinOpIdentity(SelectInst &Sel,
9696

9797
// Last, match the compare variable operand with a binop operand.
9898
Value *Y;
99-
if (!BO->isCommutative() && !match(BO, m_BinOp(m_Value(Y), m_Specific(X))))
100-
return nullptr;
101-
if (!match(BO, m_c_BinOp(m_Value(Y), m_Specific(X))))
102-
return nullptr;
99+
if (BO->isCommutative()) {
100+
if (!match(BO, m_c_BinOp(m_Value(Y), m_Specific(X))))
101+
return nullptr;
102+
} else {
103+
if (!match(BO, m_BinOp(m_Value(Y), m_Specific(X))))
104+
return nullptr;
105+
}
103106

104107
// +0.0 compares equal to -0.0, and so it does not behave as required for this
105108
// transform. Bail out if we can not exclude that possibility.

0 commit comments

Comments
 (0)