[llvm] [InstCombine] Initialize a SmallVector with a range (NFC) (PR #100947)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 28 13:49:31 PDT 2024


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/100947

None

>From 3737942efbb800228342b72746b090658e96077c Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 28 Jul 2024 13:44:27 -0700
Subject: [PATCH] [InstCombine] Initialize a SmallVector with a range (NFC)

---
 llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index e61480d7542d7..3d6b72e5775bd 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1500,10 +1500,7 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
   // Don't try to simplify calls without uses. It will not do anything useful,
   // but will result in the following folds being skipped.
   if (!CI.use_empty()) {
-    SmallVector<Value *, 8> Args;
-    Args.reserve(CI.arg_size());
-    for (Value *Op : CI.args())
-      Args.push_back(Op);
+    SmallVector<Value *, 8> Args(CI.args());
     if (Value *V = simplifyCall(&CI, CI.getCalledOperand(), Args,
                                 SQ.getWithInstruction(&CI)))
       return replaceInstUsesWith(CI, V);



More information about the llvm-commits mailing list