[llvm] [InstCombine] Missing optimization: fold mul (select a, b), (select b, a) to mul a, b (PR #74953)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 9 22:03:55 PST 2023


================
@@ -4217,3 +4220,25 @@ InstCombinerImpl::transformCallThroughTrampoline(CallBase &Call,
   Call.setCalledFunction(FTy, NestF);
   return &Call;
 }
+
+// op(select(%v, %x, %y), select(%v, %y, %x)) --> op(%x, %y)
+Instruction *
+InstCombinerImpl::foldCommutativeIntrinsicOverSelects(IntrinsicInst &II) {
+  if (!II.isCommutative()) {
----------------
dtcxzyw wrote:

It has been checked by outer if statement. I think there should be an assertion here.

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


More information about the llvm-commits mailing list