[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:15 PST 2023


================
@@ -4237,3 +4240,22 @@ InstCombinerImpl::foldCommutativeIntrinsicOverSelects(IntrinsicInst &II) {
 
   return nullptr;
 }
+
+Instruction *
+InstCombinerImpl::foldCommutativeIntrinsicOverPhis(IntrinsicInst &II) {
+  assert(II.isCommutative());
----------------
dtcxzyw wrote:

```suggestion
  assert(II.isCommutative() && "Instruction should be commutative");
```


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


More information about the llvm-commits mailing list