[llvm] [InstCombine] Missing optimization: fold mul (select a, b), (select b, a) to mul a, b (PR #74953)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 9 23:04:19 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()) {
+ return nullptr;
+ }
+
+ Value *A, *B, *C, *D, *E, *F;
+ bool LHSIsSelect =
+ match(II.getOperand(0), m_Select(m_Value(A), m_Value(B), m_Value(C)));
+ bool RHSIsSelect =
+ match(II.getOperand(1), m_Select(m_Value(D), m_Value(E), m_Value(F)));
+
----------------
goldsteinn wrote:
Maybe use `m_Specific` here instead of manually checking in condition below.
https://github.com/llvm/llvm-project/pull/74953
More information about the llvm-commits
mailing list