[llvm] [IR] Use SmallVector::append to replace a loop. (PR #143586)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 10 12:08:39 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-ir

Author: Craig Topper (topperc)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/143586.diff


1 Files Affected:

- (modified) llvm/lib/IR/Instructions.cpp (+1-2) 


``````````diff
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index b29969657e7fc..54d779b28d05b 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -1865,8 +1865,7 @@ void ShuffleVectorInst::getShuffleMask(const Constant *Mask,
     assert((isa<ConstantAggregateZero>(Mask) || isa<UndefValue>(Mask)) &&
            "Scalable vector shuffle mask must be undef or zeroinitializer");
     int MaskVal = isa<UndefValue>(Mask) ? -1 : 0;
-    for (unsigned I = 0; I < EC.getKnownMinValue(); ++I)
-      Result.emplace_back(MaskVal);
+    Result.append(EC.getKnownMinValue(), MaskVal);
     return;
   }
 

``````````

</details>


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


More information about the llvm-commits mailing list