[llvm] eb1617a - [InstCombineVectorOps] Use poison instead of undef as placeholder [NFC]
Nuno Lopes via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 29 07:58:05 PDT 2023
Author: Nuno Lopes
Date: 2023-07-29T15:28:13+01:00
New Revision: eb1617a5821c35d862ff76e1e0223443c4591ff1
URL: https://github.com/llvm/llvm-project/commit/eb1617a5821c35d862ff76e1e0223443c4591ff1
DIFF: https://github.com/llvm/llvm-project/commit/eb1617a5821c35d862ff76e1e0223443c4591ff1.diff
LOG: [InstCombineVectorOps] Use poison instead of undef as placeholder [NFC]
It's used to create a vector where only 1 element is used
While at it, change OOB extractelement to yield poison per LangRef
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
llvm/test/Transforms/InstCombine/insert-extract-shuffle-inseltpoison.ll
llvm/test/Transforms/InstCombine/insert-extract-shuffle.ll
llvm/test/Transforms/InstCombine/vscale_extractelement.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
index 4a5ffef2b08ed4..ce370a5e4ef4f2 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -441,7 +441,7 @@ Instruction *InstCombinerImpl::visitExtractElementInst(ExtractElementInst &EI) {
if (IndexC->getValue().getActiveBits() <= BitWidth)
Idx = ConstantInt::get(Ty, IndexC->getValue().zextOrTrunc(BitWidth));
else
- Idx = UndefValue::get(Ty);
+ Idx = PoisonValue::get(Ty);
return replaceInstUsesWith(EI, Idx);
}
}
@@ -2197,9 +2197,9 @@ static Instruction *canonicalizeInsertSplat(ShuffleVectorInst &Shuf,
!match(Op1, m_Undef()) || match(Mask, m_ZeroMask()) || IndexC == 0)
return nullptr;
- // Insert into element 0 of an undef vector.
- UndefValue *UndefVec = UndefValue::get(Shuf.getType());
- Value *NewIns = Builder.CreateInsertElement(UndefVec, X, (uint64_t)0);
+ // Insert into element 0 of a poison vector.
+ PoisonValue *PoisonVec = PoisonValue::get(Shuf.getType());
+ Value *NewIns = Builder.CreateInsertElement(PoisonVec, X, (uint64_t)0);
// Splat from element 0. Any mask element that is undefined remains undefined.
// For example:
diff --git a/llvm/test/Transforms/InstCombine/insert-extract-shuffle-inseltpoison.ll b/llvm/test/Transforms/InstCombine/insert-extract-shuffle-inseltpoison.ll
index 202182d4dfa71e..76ce605463c609 100644
--- a/llvm/test/Transforms/InstCombine/insert-extract-shuffle-inseltpoison.ll
+++ b/llvm/test/Transforms/InstCombine/insert-extract-shuffle-inseltpoison.ll
@@ -427,7 +427,7 @@ define <5 x float> @insert_not_undef_shuffle_translate_commute_lengthen(float %x
define <4 x float> @insert_nonzero_index_splat(float %x) {
; CHECK-LABEL: @insert_nonzero_index_splat(
-; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x float> undef, float [[X:%.*]], i64 0
+; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x float> poison, float [[X:%.*]], i64 0
; CHECK-NEXT: [[SPLAT:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> poison, <4 x i32> <i32 poison, i32 0, i32 0, i32 poison>
; CHECK-NEXT: ret <4 x float> [[SPLAT]]
;
@@ -438,7 +438,7 @@ define <4 x float> @insert_nonzero_index_splat(float %x) {
define <3 x double> @insert_nonzero_index_splat_narrow(double %x) {
; CHECK-LABEL: @insert_nonzero_index_splat_narrow(
-; CHECK-NEXT: [[TMP1:%.*]] = insertelement <3 x double> undef, double [[X:%.*]], i64 0
+; CHECK-NEXT: [[TMP1:%.*]] = insertelement <3 x double> poison, double [[X:%.*]], i64 0
; CHECK-NEXT: [[SPLAT:%.*]] = shufflevector <3 x double> [[TMP1]], <3 x double> poison, <3 x i32> <i32 0, i32 poison, i32 0>
; CHECK-NEXT: ret <3 x double> [[SPLAT]]
;
@@ -449,7 +449,7 @@ define <3 x double> @insert_nonzero_index_splat_narrow(double %x) {
define <5 x i7> @insert_nonzero_index_splat_widen(i7 %x) {
; CHECK-LABEL: @insert_nonzero_index_splat_widen(
-; CHECK-NEXT: [[TMP1:%.*]] = insertelement <5 x i7> undef, i7 [[X:%.*]], i64 0
+; CHECK-NEXT: [[TMP1:%.*]] = insertelement <5 x i7> poison, i7 [[X:%.*]], i64 0
; CHECK-NEXT: [[SPLAT:%.*]] = shufflevector <5 x i7> [[TMP1]], <5 x i7> poison, <5 x i32> <i32 poison, i32 0, i32 0, i32 poison, i32 0>
; CHECK-NEXT: ret <5 x i7> [[SPLAT]]
;
diff --git a/llvm/test/Transforms/InstCombine/insert-extract-shuffle.ll b/llvm/test/Transforms/InstCombine/insert-extract-shuffle.ll
index 7ce50a717d1924..233fd4b008045d 100644
--- a/llvm/test/Transforms/InstCombine/insert-extract-shuffle.ll
+++ b/llvm/test/Transforms/InstCombine/insert-extract-shuffle.ll
@@ -427,7 +427,7 @@ define <5 x float> @insert_not_undef_shuffle_translate_commute_lengthen(float %x
define <4 x float> @insert_nonzero_index_splat(float %x) {
; CHECK-LABEL: @insert_nonzero_index_splat(
-; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x float> undef, float [[X:%.*]], i64 0
+; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x float> poison, float [[X:%.*]], i64 0
; CHECK-NEXT: [[SPLAT:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> poison, <4 x i32> <i32 poison, i32 0, i32 0, i32 poison>
; CHECK-NEXT: ret <4 x float> [[SPLAT]]
;
@@ -438,7 +438,7 @@ define <4 x float> @insert_nonzero_index_splat(float %x) {
define <3 x double> @insert_nonzero_index_splat_narrow(double %x) {
; CHECK-LABEL: @insert_nonzero_index_splat_narrow(
-; CHECK-NEXT: [[TMP1:%.*]] = insertelement <3 x double> undef, double [[X:%.*]], i64 0
+; CHECK-NEXT: [[TMP1:%.*]] = insertelement <3 x double> poison, double [[X:%.*]], i64 0
; CHECK-NEXT: [[SPLAT:%.*]] = shufflevector <3 x double> [[TMP1]], <3 x double> poison, <3 x i32> <i32 0, i32 poison, i32 0>
; CHECK-NEXT: ret <3 x double> [[SPLAT]]
;
@@ -449,7 +449,7 @@ define <3 x double> @insert_nonzero_index_splat_narrow(double %x) {
define <5 x i7> @insert_nonzero_index_splat_widen(i7 %x) {
; CHECK-LABEL: @insert_nonzero_index_splat_widen(
-; CHECK-NEXT: [[TMP1:%.*]] = insertelement <5 x i7> undef, i7 [[X:%.*]], i64 0
+; CHECK-NEXT: [[TMP1:%.*]] = insertelement <5 x i7> poison, i7 [[X:%.*]], i64 0
; CHECK-NEXT: [[SPLAT:%.*]] = shufflevector <5 x i7> [[TMP1]], <5 x i7> poison, <5 x i32> <i32 poison, i32 0, i32 0, i32 poison, i32 0>
; CHECK-NEXT: ret <5 x i7> [[SPLAT]]
;
diff --git a/llvm/test/Transforms/InstCombine/vscale_extractelement.ll b/llvm/test/Transforms/InstCombine/vscale_extractelement.ll
index 8c97f4246c6d09..784229c948a6d3 100644
--- a/llvm/test/Transforms/InstCombine/vscale_extractelement.ll
+++ b/llvm/test/Transforms/InstCombine/vscale_extractelement.ll
@@ -217,12 +217,12 @@ entry:
ret i64 %1
}
-; Check that undef is returned when the extracted element has wrapped.
+; Check that poison is returned when the extracted element has wrapped.
define i8 @ext_lane256_from_stepvec() {
; CHECK-LABEL: @ext_lane256_from_stepvec(
; CHECK-NEXT: entry:
-; CHECK-NEXT: ret i8 undef
+; CHECK-NEXT: ret i8 poison
;
entry:
%0 = call <vscale x 512 x i8> @llvm.experimental.stepvector.nxv512i8()
More information about the llvm-commits
mailing list