[llvm] [InstCombine] Use constant 64-bit indices for InsertElement (PR #209017)
Andreas Jonson via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 12 06:29:03 PDT 2026
https://github.com/andjo403 created https://github.com/llvm/llvm-project/pull/209017
The canonical form preferred by instCombine is to use 64-bit values for constant index in InsertElement see
https://github.com/llvm/llvm-project/blob/9d5d8834793da9efe297620db3ef39633688f830/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp#L401-L411
missed one insertElement in https://github.com/llvm/llvm-project/pull/208306
>From 328957b2b4d73acfab7cd4b7d76dcf6460679048 Mon Sep 17 00:00:00 2001
From: Andreas Jonson <andjo403 at hotmail.com>
Date: Sun, 12 Jul 2026 15:27:17 +0200
Subject: [PATCH] [InstCombine] Use constant 64-bit indices for InsertElement
---
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index f30a7b5e891ab..fb196aec7946b 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -3004,8 +3004,7 @@ static Value *optimizeIntegerToVectorInsertions(BitCastInst &CI,
for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
if (!Elements[i]) continue; // Unset element.
- Result = IC.Builder.CreateInsertElement(Result, Elements[i],
- IC.Builder.getInt32(i));
+ Result = IC.Builder.CreateInsertElement(Result, Elements[i], i);
}
return Result;
More information about the llvm-commits
mailing list