Skip to content

[CodeGen] Construct SmallVector with ArrayRef (NFC) #135930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

kazutakahirata
Copy link
Contributor

Note that we can drop the call to reserve because the constructor that
takes ArrayRef calls append, which in turn calls reserve.

Note that we can drop the call to reserve because the constructor that
takes ArrayRef calls append, which in turn calls reserve.
@kazutakahirata kazutakahirata requested a review from kuhar April 16, 2025 07:56
@llvmbot llvmbot added the llvm:SelectionDAG SelectionDAGISel as well label Apr 16, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 16, 2025

@llvm/pr-subscribers-llvm-selectiondag

Author: Kazu Hirata (kazutakahirata)

Changes

Note that we can drop the call to reserve because the constructor that
takes ArrayRef calls append, which in turn calls reserve.


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

1 Files Affected:

  • (modified) llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (+1-3)
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index d72be359867ca..8322d243b5bc3 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -24741,10 +24741,8 @@ static SDValue combineConcatVectorOfShuffleAndItsOperands(
 
   // We are going to pad the shuffle operands, so any indice, that was picking
   // from the second operand, must be adjusted.
-  SmallVector<int, 16> AdjustedMask;
-  AdjustedMask.reserve(SVN->getMask().size());
+  SmallVector<int, 16> AdjustedMask(SVN->getMask());
   assert(SVN->getOperand(1).isUndef() && "Expected unary shuffle!");
-  append_range(AdjustedMask, SVN->getMask());
 
   // Identity masks for the operands of the (padded) shuffle.
   SmallVector<int, 32> IdentityMask(2 * OpVT.getVectorNumElements());

Copy link
Collaborator

@RKSimon RKSimon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (I'm assuming the CI break is unrelated)

@kazutakahirata kazutakahirata merged commit 81b4fc2 into llvm:main Apr 16, 2025
11 of 13 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_SmallVector_ArrayRef_llvm_CodeGen branch April 16, 2025 15:37
var-const pushed a commit to ldionne/llvm-project that referenced this pull request Apr 17, 2025
Note that we can drop the call to reserve because the constructor that
takes ArrayRef calls append, which in turn calls reserve.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm:SelectionDAG SelectionDAGISel as well
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants