[llvm] [InstCombine] Constant fold binops through `vector.insert` (PR #164624)
    Paul Walker via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Thu Oct 23 04:04:26 PDT 2025
    
    
  
================
@@ -2323,6 +2323,32 @@ Constant *InstCombinerImpl::unshuffleConstant(ArrayRef<int> ShMask, Constant *C,
   return ConstantVector::get(NewVecC);
 }
 
+// Match a vector.insert where both the destination and subvector are constant.
+static bool matchConstantSubVector(Value *V, Constant *&Dest,
+                                   Constant *&SubVector, Value *&Idx) {
+  return match(V, m_Intrinsic<Intrinsic::vector_insert>(
+                      m_Constant(Dest), m_Constant(SubVector), m_Value(Idx)));
+}
+
+static Constant *matchConstantSplat(Value *V) {
+  Constant *C;
+  if (match(V, m_Constant(C)))
+    return C->getSplatValue();
----------------
paulwalker-arm wrote:
```suggestion
  if (auto *C = dyn_cast<Constant>(V))
    return C->getSplatValue();
```
https://github.com/llvm/llvm-project/pull/164624
    
    
More information about the llvm-commits
mailing list