[llvm] [VectorCombine] Scalarize binop-like intrinsics (PR #138095)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Fri May 2 05:06:59 PDT 2025


================
@@ -1016,21 +1017,34 @@ bool VectorCombine::scalarizeVPIntrinsic(Instruction &I) {
   return true;
 }
 
-/// Match a vector binop or compare instruction with at least one inserted
-/// scalar operand and convert to scalar binop/cmp followed by insertelement.
+/// Match a vector binop, compare or binop-like intrinsic with at least one
+/// inserted scalar operand and convert to scalar binop/cmp/intrinsic followed
+/// by insertelement.
 bool VectorCombine::scalarizeBinopOrCmp(Instruction &I) {
   CmpPredicate Pred = CmpInst::BAD_ICMP_PREDICATE;
   Value *Ins0, *Ins1;
   if (!match(&I, m_BinOp(m_Value(Ins0), m_Value(Ins1))) &&
-      !match(&I, m_Cmp(Pred, m_Value(Ins0), m_Value(Ins1))))
-    return false;
+      !match(&I, m_Cmp(Pred, m_Value(Ins0), m_Value(Ins1)))) {
+    // TODO: Allow unary and ternary intrinsics
+    // TODO: Allow intrinsics with different argument types
+    // TODO: Allow intrinsics with scalar arguments
----------------
RKSimon wrote:

if we do want to support these (and FMA is probably the most useful to add) - pulling out intrinsics into their own methods would make sense - similar to foldShuffleOfBinops/foldShuffleOfIntrinsics

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


More information about the llvm-commits mailing list