[llvm] [InstCombine] Fold binary op of reductions. (PR #121567)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 3 05:27:18 PST 2025


================
@@ -2296,6 +2296,58 @@ Instruction *InstCombinerImpl::foldVectorBinop(BinaryOperator &Inst) {
   return nullptr;
 }
 
+static Intrinsic::ID getReductionForBinop(Instruction::BinaryOps Opc) {
+  switch (Opc) {
+  default:
+    break;
+  case Instruction::Add:
+    return Intrinsic::vector_reduce_add;
+  case Instruction::Mul:
+    return Intrinsic::vector_reduce_mul;
+  case Instruction::And:
+    return Intrinsic::vector_reduce_and;
+  case Instruction::Or:
+    return Intrinsic::vector_reduce_or;
+  case Instruction::Xor:
+    return Intrinsic::vector_reduce_xor;
+  }
+  return Intrinsic::num_intrinsics;
----------------
dtcxzyw wrote:

Use `Intrinsic::not_intrinsic`

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


More information about the llvm-commits mailing list