[llvm] [InstCombine] fold (Binop phi(a, b) phi(b, a)) -> (Binop a, b) while Binop is commutative. (PR #75765)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 18 00:30:16 PST 2023


================
@@ -1096,6 +1096,50 @@ Value *InstCombinerImpl::foldUsingDistributiveLaws(BinaryOperator &I) {
   return SimplifySelectsFeedingBinaryOp(I, LHS, RHS);
 }
 
+bool InstCombinerImpl::matchSymmetricPhiNodesPair(PHINode *LHS, PHINode *RHS) {
+
+  if (LHS->getNumOperands() != 2 || RHS->getNumOperands() != 2)
----------------
dtcxzyw wrote:

```suggestion
  if (LHS->getNumIncomingValues() != 2 || RHS->getNumIncomingValues() != 2)
```
It would be clearer than `getNumOperands`.


https://github.com/llvm/llvm-project/pull/75765


More information about the llvm-commits mailing list