[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
Wed Sep 22 23:55:43 PDT 2021
hyeongyukim created this revision.
Herald added subscribers: dexonsmith, kbarton, hiraditya, nemanjai, jholewinski.
hyeongyukim requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This patch is for fixing potential insertElement-related bugs like D93818 <https://reviews.llvm.org/D93818>.
V = UndefValue::get(VecTy);
for(...)
V = Builder.CreateInsertElementy(V, Elt, Idx);
Like above, this patch changes the placeholder V to poison.
The patch will be separated into several commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D110311
Files:
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp
llvm/lib/Target/PowerPC/PPCTargetTransformInfo.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,8 @@
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 *PoisonVec = PoisonValue::get(VecTy);
+ Value *VI1 = IRB.CreateInsertElement(PoisonVec, 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,7 +878,7 @@
auto VecTy = FixedVectorType::get(Builder.getInt64Ty(), 4);
auto Elt1 = Builder.getInt64(-1);
auto Elt2 = Builder.getInt64(-2);
- Value *Vec = UndefValue::get(VecTy);
+ Value *Vec = PoisonValue::get(VecTy);
Vec = Builder.CreateInsertElement(Vec, Elt1, Builder.getInt8(1));
Vec = Builder.CreateInsertElement(Vec, Elt2, 2);
auto X1 = Builder.CreateExtractElement(Vec, 1);
Index: llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
+++ llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
@@ -133,7 +133,7 @@
IC.Builder.CreateBitCast(II.getArgOperand(0), Mask->getType());
Value *Op1 =
IC.Builder.CreateBitCast(II.getArgOperand(1), Mask->getType());
- Value *Result = UndefValue::get(Op0->getType());
+ Value *Result = PoisonValue::get(Op0->getType());
// Only extract each element once.
Value *ExtractedElts[32];
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));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110311.374452.patch
Type: text/x-patch
Size: 3251 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210923/98a61d0d/attachment.bin>
More information about the llvm-commits
mailing list