InstCombine: use poison instead of undef as placeholder in insertvalue [NFC]

These vectors are fully initialized so the placeholder value is irrelevant
This commit is contained in:
Nuno Lopes 2022-08-14 21:37:23 +01:00
parent aacf1a9742
commit 0299ebc1bd
3 changed files with 18 additions and 18 deletions
llvm
lib/Transforms/InstCombine
test/Transforms/InstCombine

View File

@ -3461,7 +3461,7 @@ bool InstCombinerImpl::transformConstExprCastCall(CallBase &Call) {
}
Worklist.pushUsersToWorkList(*Caller);
} else {
NV = UndefValue::get(Caller->getType());
NV = PoisonValue::get(Caller->getType());
}
}

View File

@ -639,7 +639,7 @@ static Instruction *unpackLoadToAggregate(InstCombinerImpl &IC, LoadInst &LI) {
".unpack");
NewLoad->setAAMetadata(LI.getAAMetadata());
return IC.replaceInstUsesWith(LI, IC.Builder.CreateInsertValue(
UndefValue::get(T), NewLoad, 0, Name));
PoisonValue::get(T), NewLoad, 0, Name));
}
// We don't want to break loads with padding here as we'd loose
@ -654,7 +654,7 @@ static Instruction *unpackLoadToAggregate(InstCombinerImpl &IC, LoadInst &LI) {
auto *IdxType = Type::getInt32Ty(T->getContext());
auto *Zero = ConstantInt::get(IdxType, 0);
Value *V = UndefValue::get(T);
Value *V = PoisonValue::get(T);
for (unsigned i = 0; i < NumElements; i++) {
Value *Indices[2] = {
Zero,
@ -681,7 +681,7 @@ static Instruction *unpackLoadToAggregate(InstCombinerImpl &IC, LoadInst &LI) {
LoadInst *NewLoad = IC.combineLoadToNewType(LI, ET, ".unpack");
NewLoad->setAAMetadata(LI.getAAMetadata());
return IC.replaceInstUsesWith(LI, IC.Builder.CreateInsertValue(
UndefValue::get(T), NewLoad, 0, Name));
PoisonValue::get(T), NewLoad, 0, Name));
}
// Bail out if the array is too large. Ideally we would like to optimize
@ -699,7 +699,7 @@ static Instruction *unpackLoadToAggregate(InstCombinerImpl &IC, LoadInst &LI) {
auto *IdxType = Type::getInt64Ty(T->getContext());
auto *Zero = ConstantInt::get(IdxType, 0);
Value *V = UndefValue::get(T);
Value *V = PoisonValue::get(T);
uint64_t Offset = 0;
for (uint64_t i = 0; i < NumElements; i++) {
Value *Indices[2] = {

View File

@ -60,7 +60,7 @@ define void @storeLargeArrayOfA([2000 x %A]* %aa.ptr) {
; CHECK-NEXT: store [2000 x %A]
; CHECK-NEXT: ret void
;
%i1 = insertvalue [2000 x %A] undef, %A { %A__vtbl* @A__vtblZ }, 1
%i1 = insertvalue [2000 x %A] poison, %A { %A__vtbl* @A__vtblZ }, 1
store [2000 x %A] %i1, [2000 x %A]* %aa.ptr, align 8
ret void
}
@ -102,7 +102,7 @@ define %A @loadA(%A* %a.ptr) {
; CHECK-LABEL: @loadA(
; CHECK-NEXT: [[TMP1:%.*]] = getelementptr [[A:%.*]], %A* [[A_PTR:%.*]], i64 0, i32 0
; CHECK-NEXT: [[DOTUNPACK:%.*]] = load %A__vtbl*, %A__vtbl** [[TMP1]], align 8
; CHECK-NEXT: [[TMP2:%.*]] = insertvalue [[A]] undef, %A__vtbl* [[DOTUNPACK]], 0
; CHECK-NEXT: [[TMP2:%.*]] = insertvalue [[A]] poison, %A__vtbl* [[DOTUNPACK]], 0
; CHECK-NEXT: ret [[A]] [[TMP2]]
;
%1 = load %A, %A* %a.ptr, align 8
@ -113,7 +113,7 @@ define %B @loadB(%B* %b.ptr) {
; CHECK-LABEL: @loadB(
; CHECK-NEXT: [[DOTELT:%.*]] = getelementptr inbounds [[B:%.*]], %B* [[B_PTR:%.*]], i64 0, i32 0
; CHECK-NEXT: [[DOTUNPACK:%.*]] = load i8*, i8** [[DOTELT]], align 8
; CHECK-NEXT: [[TMP1:%.*]] = insertvalue [[B]] undef, i8* [[DOTUNPACK]], 0
; CHECK-NEXT: [[TMP1:%.*]] = insertvalue [[B]] poison, i8* [[DOTUNPACK]], 0
; CHECK-NEXT: [[DOTELT1:%.*]] = getelementptr inbounds [[B]], %B* [[B_PTR]], i64 0, i32 1
; CHECK-NEXT: [[DOTUNPACK2:%.*]] = load i64, i64* [[DOTELT1]], align 8
; CHECK-NEXT: [[TMP2:%.*]] = insertvalue [[B]] [[TMP1]], i64 [[DOTUNPACK2]], 1
@ -127,8 +127,8 @@ define { %A } @loadStructOfA({ %A }* %sa.ptr) {
; CHECK-LABEL: @loadStructOfA(
; CHECK-NEXT: [[TMP1:%.*]] = getelementptr { [[A:%.*]] }, { [[A]] }* [[SA_PTR:%.*]], i64 0, i32 0, i32 0
; CHECK-NEXT: [[DOTUNPACK_UNPACK:%.*]] = load %A__vtbl*, %A__vtbl** [[TMP1]], align 8
; CHECK-NEXT: [[DOTUNPACK1:%.*]] = insertvalue [[A]] undef, %A__vtbl* [[DOTUNPACK_UNPACK]], 0
; CHECK-NEXT: [[TMP2:%.*]] = insertvalue { [[A]] } undef, [[A]] [[DOTUNPACK1]], 0
; CHECK-NEXT: [[DOTUNPACK1:%.*]] = insertvalue [[A]] poison, %A__vtbl* [[DOTUNPACK_UNPACK]], 0
; CHECK-NEXT: [[TMP2:%.*]] = insertvalue { [[A]] } poison, [[A]] [[DOTUNPACK1]], 0
; CHECK-NEXT: ret { [[A]] } [[TMP2]]
;
%1 = load { %A }, { %A }* %sa.ptr, align 8
@ -139,8 +139,8 @@ define [1 x %A] @loadArrayOfA([1 x %A]* %aa.ptr) {
; CHECK-LABEL: @loadArrayOfA(
; CHECK-NEXT: [[TMP1:%.*]] = getelementptr [1 x %A], [1 x %A]* [[AA_PTR:%.*]], i64 0, i64 0, i32 0
; CHECK-NEXT: [[DOTUNPACK_UNPACK:%.*]] = load %A__vtbl*, %A__vtbl** [[TMP1]], align 8
; CHECK-NEXT: [[DOTUNPACK1:%.*]] = insertvalue [[A:%.*]] undef, %A__vtbl* [[DOTUNPACK_UNPACK]], 0
; CHECK-NEXT: [[TMP2:%.*]] = insertvalue [1 x %A] undef, [[A]] [[DOTUNPACK1]], 0
; CHECK-NEXT: [[DOTUNPACK1:%.*]] = insertvalue [[A:%.*]] poison, %A__vtbl* [[DOTUNPACK_UNPACK]], 0
; CHECK-NEXT: [[TMP2:%.*]] = insertvalue [1 x %A] poison, [[A]] [[DOTUNPACK1]], 0
; CHECK-NEXT: ret [1 x %A] [[TMP2]]
;
%1 = load [1 x %A], [1 x %A]* %aa.ptr, align 8
@ -151,9 +151,9 @@ define { [1 x %A] } @loadStructOfArrayOfA({ [1 x %A] }* %saa.ptr) {
; CHECK-LABEL: @loadStructOfArrayOfA(
; CHECK-NEXT: [[TMP1:%.*]] = getelementptr { [1 x %A] }, { [1 x %A] }* [[SAA_PTR:%.*]], i64 0, i32 0, i64 0, i32 0
; CHECK-NEXT: [[DOTUNPACK_UNPACK_UNPACK:%.*]] = load %A__vtbl*, %A__vtbl** [[TMP1]], align 8
; CHECK-NEXT: [[DOTUNPACK_UNPACK2:%.*]] = insertvalue [[A:%.*]] undef, %A__vtbl* [[DOTUNPACK_UNPACK_UNPACK]], 0
; CHECK-NEXT: [[DOTUNPACK1:%.*]] = insertvalue [1 x %A] undef, [[A]] [[DOTUNPACK_UNPACK2]], 0
; CHECK-NEXT: [[TMP2:%.*]] = insertvalue { [1 x %A] } undef, [1 x %A] [[DOTUNPACK1]], 0
; CHECK-NEXT: [[DOTUNPACK_UNPACK2:%.*]] = insertvalue [[A:%.*]] poison, %A__vtbl* [[DOTUNPACK_UNPACK_UNPACK]], 0
; CHECK-NEXT: [[DOTUNPACK1:%.*]] = insertvalue [1 x %A] poison, [[A]] [[DOTUNPACK_UNPACK2]], 0
; CHECK-NEXT: [[TMP2:%.*]] = insertvalue { [1 x %A] } poison, [1 x %A] [[DOTUNPACK1]], 0
; CHECK-NEXT: ret { [1 x %A] } [[TMP2]]
;
%1 = load { [1 x %A] }, { [1 x %A] }* %saa.ptr, align 8
@ -188,14 +188,14 @@ define [2 x %B] @loadArrayOfB([2 x %B]* %ab.ptr) {
; CHECK-LABEL: @loadArrayOfB(
; CHECK-NEXT: [[DOTUNPACK_ELT:%.*]] = getelementptr inbounds [2 x %B], [2 x %B]* [[AB_PTR:%.*]], i64 0, i64 0, i32 0
; CHECK-NEXT: [[DOTUNPACK_UNPACK:%.*]] = load i8*, i8** [[DOTUNPACK_ELT]], align 8
; CHECK-NEXT: [[TMP1:%.*]] = insertvalue [[B:%.*]] undef, i8* [[DOTUNPACK_UNPACK]], 0
; CHECK-NEXT: [[TMP1:%.*]] = insertvalue [[B:%.*]] poison, i8* [[DOTUNPACK_UNPACK]], 0
; CHECK-NEXT: [[DOTUNPACK_ELT3:%.*]] = getelementptr inbounds [2 x %B], [2 x %B]* [[AB_PTR]], i64 0, i64 0, i32 1
; CHECK-NEXT: [[DOTUNPACK_UNPACK4:%.*]] = load i64, i64* [[DOTUNPACK_ELT3]], align 8
; CHECK-NEXT: [[DOTUNPACK5:%.*]] = insertvalue [[B]] [[TMP1]], i64 [[DOTUNPACK_UNPACK4]], 1
; CHECK-NEXT: [[TMP2:%.*]] = insertvalue [2 x %B] undef, [[B]] [[DOTUNPACK5]], 0
; CHECK-NEXT: [[TMP2:%.*]] = insertvalue [2 x %B] poison, [[B]] [[DOTUNPACK5]], 0
; CHECK-NEXT: [[DOTUNPACK2_ELT:%.*]] = getelementptr inbounds [2 x %B], [2 x %B]* [[AB_PTR]], i64 0, i64 1, i32 0
; CHECK-NEXT: [[DOTUNPACK2_UNPACK:%.*]] = load i8*, i8** [[DOTUNPACK2_ELT]], align 8
; CHECK-NEXT: [[TMP3:%.*]] = insertvalue [[B]] undef, i8* [[DOTUNPACK2_UNPACK]], 0
; CHECK-NEXT: [[TMP3:%.*]] = insertvalue [[B]] poison, i8* [[DOTUNPACK2_UNPACK]], 0
; CHECK-NEXT: [[DOTUNPACK2_ELT6:%.*]] = getelementptr inbounds [2 x %B], [2 x %B]* [[AB_PTR]], i64 0, i64 1, i32 1
; CHECK-NEXT: [[DOTUNPACK2_UNPACK7:%.*]] = load i64, i64* [[DOTUNPACK2_ELT6]], align 8
; CHECK-NEXT: [[DOTUNPACK28:%.*]] = insertvalue [[B]] [[TMP3]], i64 [[DOTUNPACK2_UNPACK7]], 1