[PATCH] D110311: [IR] Change the default value of InstertElement to poison (1/4)
Hyeongyu Kim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 27 21:55:45 PDT 2021
hyeongyukim updated this revision to Diff 375470.
hyeongyukim added a comment.
Add the new CreateInsertElement
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110311/new/
https://reviews.llvm.org/D110311
Files:
llvm/include/llvm/IR/IRBuilder.h
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp
llvm/unittests/IR/IRBuilderTest.cpp
llvm/unittests/IR/PatternMatch.cpp
Index: llvm/unittests/IR/PatternMatch.cpp
===================================================================
--- llvm/unittests/IR/PatternMatch.cpp
+++ llvm/unittests/IR/PatternMatch.cpp
@@ -940,8 +940,7 @@
VecElemIdxs.push_back(ConstantInt::get(i32, 2));
auto *IdxVec = ConstantVector::get(VecElemIdxs);
- Value *UndefVec = UndefValue::get(VecTy);
- Value *VI1 = IRB.CreateInsertElement(UndefVec, IRB.getInt8(1), (uint64_t)0);
+ Value *VI1 = IRB.CreateInsertElement(VecTy, IRB.getInt8(1), (uint64_t)0);
Value *VI2 = IRB.CreateInsertElement(VI1, Val2, Val);
Value *VI3 = IRB.CreateInsertElement(VI1, Val2, (uint64_t)1);
Value *VI4 = IRB.CreateInsertElement(VI1, IRB.getInt8(2), Val);
Index: llvm/unittests/IR/IRBuilderTest.cpp
===================================================================
--- llvm/unittests/IR/IRBuilderTest.cpp
+++ llvm/unittests/IR/IRBuilderTest.cpp
@@ -878,8 +878,7 @@
auto VecTy = FixedVectorType::get(Builder.getInt64Ty(), 4);
auto Elt1 = Builder.getInt64(-1);
auto Elt2 = Builder.getInt64(-2);
- Value *Vec = UndefValue::get(VecTy);
- Vec = Builder.CreateInsertElement(Vec, Elt1, Builder.getInt8(1));
+ Value* Vec = Builder.CreateInsertElement(VecTy, Elt1, Builder.getInt8(1));
Vec = Builder.CreateInsertElement(Vec, Elt2, 2);
auto X1 = Builder.CreateExtractElement(Vec, 1);
auto X2 = Builder.CreateExtractElement(Vec, Builder.getInt32(2));
Index: llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp
===================================================================
--- llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp
+++ llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp
@@ -212,7 +212,7 @@
// If any of the elements has been modified, construct the equivalent
// vector or aggregate value with a set instructions and the converted
// elements.
- Value *NewValue = UndefValue::get(C->getType());
+ Value *NewValue = PoisonValue::get(C->getType());
if (isa<ConstantVector>(C)) {
for (unsigned i = 0; i < NumOperands; ++i) {
Value *Idx = ConstantInt::get(Type::getInt32Ty(M->getContext()), i);
Index: llvm/lib/IR/AutoUpgrade.cpp
===================================================================
--- llvm/lib/IR/AutoUpgrade.cpp
+++ llvm/lib/IR/AutoUpgrade.cpp
@@ -2417,7 +2417,7 @@
EltTy->getPointerTo());
Value *Load = Builder.CreateLoad(EltTy, Cast);
Type *I32Ty = Type::getInt32Ty(C);
- Rep = UndefValue::get(VecTy);
+ Rep = PoisonValue::get(VecTy);
for (unsigned I = 0; I < EltNum; ++I)
Rep = Builder.CreateInsertElement(Rep, Load,
ConstantInt::get(I32Ty, I));
Index: llvm/include/llvm/IR/IRBuilder.h
===================================================================
--- llvm/include/llvm/IR/IRBuilder.h
+++ llvm/include/llvm/IR/IRBuilder.h
@@ -2452,6 +2452,16 @@
return CreateExtractElement(Vec, getInt64(Idx), Name);
}
+ Value *CreateInsertElement(Type *VecTy, Value *NewElt, Value *Idx,
+ const Twine &Name = "") {
+ return CreateInsertElement(PoisonValue::get(VecTy), NewElt, Idx, Name);
+ }
+
+ Value *CreateInsertElement(Type *VecTy, Value *NewElt, uint64_t Idx,
+ const Twine &Name = "") {
+ return CreateInsertElement(PoisonValue::get(VecTy), NewElt, Idx, Name);
+ }
+
Value *CreateInsertElement(Value *Vec, Value *NewElt, Value *Idx,
const Twine &Name = "") {
if (auto *VC = dyn_cast<Constant>(Vec))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110311.375470.patch
Type: text/x-patch
Size: 3542 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210928/18a629f8/attachment.bin>
More information about the llvm-commits
mailing list