[llvm] 7659cd4 - [VectorUtils] Use PatternMatch in findScalarElement (NFC) (#168389)

via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 17 08:36:46 PST 2025


Author: Ramkumar Ramachandra
Date: 2025-11-17T16:36:42Z
New Revision: 7659cd42578c59d1bef1313053d493171b9146a2

URL: https://github.com/llvm/llvm-project/commit/7659cd42578c59d1bef1313053d493171b9146a2
DIFF: https://github.com/llvm/llvm-project/commit/7659cd42578c59d1bef1313053d493171b9146a2.diff

LOG: [VectorUtils] Use PatternMatch in findScalarElement (NFC) (#168389)

Added: 
    

Modified: 
    llvm/lib/Analysis/VectorUtils.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp
index 530fa9518f40e..a3e9b039f9225 100644
--- a/llvm/lib/Analysis/VectorUtils.cpp
+++ b/llvm/lib/Analysis/VectorUtils.cpp
@@ -317,9 +317,9 @@ Value *llvm::findScalarElement(Value *V, unsigned EltNo) {
 
   if (InsertElementInst *III = dyn_cast<InsertElementInst>(V)) {
     // If this is an insert to a variable element, we don't know what it is.
-    if (!isa<ConstantInt>(III->getOperand(2)))
+    uint64_t IIElt;
+    if (!match(III->getOperand(2), m_ConstantInt(IIElt)))
       return nullptr;
-    unsigned IIElt = cast<ConstantInt>(III->getOperand(2))->getZExtValue();
 
     // If this is an insert to the element we are looking for, return the
     // inserted value.


        


More information about the llvm-commits mailing list