Skip to content

Commit d75fb17

Browse files
committed
[VectorCombine] Use poison insteaf of undef as placeholder [NFC]
These vector lanes are never accessed. They are used for shifting a value into the right lane and therefore only 1 value of the whole vector is actually used
1 parent 569769b commit d75fb17

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,9 @@ bool VectorCombine::isExtractExtractCheap(ExtractElementInst *Ext0,
457457

458458
// If we are extracting from 2 different indexes, then one operand must be
459459
// shuffled before performing the vector operation. The shuffle mask is
460-
// undefined except for 1 lane that is being translated to the remaining
460+
// poison except for 1 lane that is being translated to the remaining
461461
// extraction lane. Therefore, it is a splat shuffle. Ex:
462-
// ShufMask = { undef, undef, 0, undef }
462+
// ShufMask = { poison, poison, 0, poison }
463463
// TODO: The cost model has an option for a "broadcast" shuffle
464464
// (splat-from-element-0), but no option for a more general splat.
465465
NewCost +=
@@ -476,9 +476,9 @@ bool VectorCombine::isExtractExtractCheap(ExtractElementInst *Ext0,
476476
/// to a new element location.
477477
static Value *createShiftShuffle(Value *Vec, unsigned OldIndex,
478478
unsigned NewIndex, IRBuilder<> &Builder) {
479-
// The shuffle mask is undefined except for 1 lane that is being translated
479+
// The shuffle mask is poison except for 1 lane that is being translated
480480
// to the new element index. Example for OldIndex == 2 and NewIndex == 0:
481-
// ShufMask = { 2, undef, undef, undef }
481+
// ShufMask = { 2, poison, poison, poison }
482482
auto *VecTy = cast<FixedVectorType>(Vec->getType());
483483
SmallVector<int, 32> ShufMask(VecTy->getNumElements(), PoisonMaskElem);
484484
ShufMask[NewIndex] = OldIndex;
@@ -929,7 +929,7 @@ bool VectorCombine::foldExtractedCmps(Instruction &I) {
929929

930930
// Create a vector constant from the 2 scalar constants.
931931
SmallVector<Constant *, 32> CmpC(VecTy->getNumElements(),
932-
UndefValue::get(VecTy->getElementType()));
932+
PoisonValue::get(VecTy->getElementType()));
933933
CmpC[Index0] = C0;
934934
CmpC[Index1] = C1;
935935
Value *VCmp = Builder.CreateCmp(Pred, X, ConstantVector::get(CmpC));

llvm/test/Transforms/VectorCombine/X86/extract-cmp-binop.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ define i1 @fcmp_or_v4f64(<4 x double> %a) {
3636
; SSE-NEXT: ret i1 [[R]]
3737
;
3838
; AVX-LABEL: @fcmp_or_v4f64(
39-
; AVX-NEXT: [[TMP1:%.*]] = fcmp olt <4 x double> [[A:%.*]], <double 4.200000e+01, double undef, double -8.000000e+00, double undef>
39+
; AVX-NEXT: [[TMP1:%.*]] = fcmp olt <4 x double> [[A:%.*]], <double 4.200000e+01, double poison, double -8.000000e+00, double poison>
4040
; AVX-NEXT: [[SHIFT:%.*]] = shufflevector <4 x i1> [[TMP1]], <4 x i1> poison, <4 x i32> <i32 2, i32 poison, i32 poison, i32 poison>
4141
; AVX-NEXT: [[TMP2:%.*]] = or <4 x i1> [[TMP1]], [[SHIFT]]
4242
; AVX-NEXT: [[R:%.*]] = extractelement <4 x i1> [[TMP2]], i64 0
@@ -52,7 +52,7 @@ define i1 @fcmp_or_v4f64(<4 x double> %a) {
5252

5353
define i1 @icmp_xor_v4i32(<4 x i32> %a) {
5454
; CHECK-LABEL: @icmp_xor_v4i32(
55-
; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt <4 x i32> [[A:%.*]], <i32 undef, i32 -8, i32 undef, i32 42>
55+
; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt <4 x i32> [[A:%.*]], <i32 poison, i32 -8, i32 poison, i32 42>
5656
; CHECK-NEXT: [[SHIFT:%.*]] = shufflevector <4 x i1> [[TMP1]], <4 x i1> poison, <4 x i32> <i32 poison, i32 3, i32 poison, i32 poison>
5757
; CHECK-NEXT: [[TMP2:%.*]] = xor <4 x i1> [[TMP1]], [[SHIFT]]
5858
; CHECK-NEXT: [[R:%.*]] = extractelement <4 x i1> [[TMP2]], i64 1
@@ -78,7 +78,7 @@ define i1 @icmp_add_v8i32(<8 x i32> %a) {
7878
; SSE-NEXT: ret i1 [[R]]
7979
;
8080
; AVX-LABEL: @icmp_add_v8i32(
81-
; AVX-NEXT: [[TMP1:%.*]] = icmp eq <8 x i32> [[A:%.*]], <i32 undef, i32 undef, i32 -8, i32 undef, i32 undef, i32 undef, i32 undef, i32 42>
81+
; AVX-NEXT: [[TMP1:%.*]] = icmp eq <8 x i32> [[A:%.*]], <i32 poison, i32 poison, i32 -8, i32 poison, i32 poison, i32 poison, i32 poison, i32 42>
8282
; AVX-NEXT: [[SHIFT:%.*]] = shufflevector <8 x i1> [[TMP1]], <8 x i1> poison, <8 x i32> <i32 poison, i32 poison, i32 7, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
8383
; AVX-NEXT: [[TMP2:%.*]] = add <8 x i1> [[TMP1]], [[SHIFT]]
8484
; AVX-NEXT: [[R:%.*]] = extractelement <8 x i1> [[TMP2]], i64 2

0 commit comments

Comments
 (0)