Skip to content

Commit f412b78

Browse files
committed
[InstCombine] Return poison if all lanes are poison
1 parent 4c887fe commit f412b78

File tree

6 files changed

+28
-28
lines changed

6 files changed

+28
-28
lines changed

llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,10 +1867,10 @@ Value *InstCombinerImpl::SimplifyDemandedVectorElts(Value *V,
18671867
PoisonElts &= PoisonElts2;
18681868
}
18691869

1870-
// If we've proven all of the lanes undef, return an undef value.
1870+
// If we've proven all of the lanes poison, return a poison value.
18711871
// TODO: Intersect w/demanded lanes
18721872
if (PoisonElts.isAllOnes())
1873-
return UndefValue::get(I->getType());
1873+
return PoisonValue::get(I->getType());
18741874

18751875
return MadeChange ? I : nullptr;
18761876
}

llvm/test/Transforms/InstCombine/X86/x86-pack-inseltpoison.ll

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,95 +7,95 @@
77

88
define <8 x i16> @poison_packssdw_128() {
99
; CHECK-LABEL: @poison_packssdw_128(
10-
; CHECK-NEXT: ret <8 x i16> undef
10+
; CHECK-NEXT: ret <8 x i16> poison
1111
;
1212
%1 = call <8 x i16> @llvm.x86.sse2.packssdw.128(<4 x i32> poison, <4 x i32> poison)
1313
ret <8 x i16> %1
1414
}
1515

1616
define <8 x i16> @poison_packusdw_128() {
1717
; CHECK-LABEL: @poison_packusdw_128(
18-
; CHECK-NEXT: ret <8 x i16> undef
18+
; CHECK-NEXT: ret <8 x i16> poison
1919
;
2020
%1 = call <8 x i16> @llvm.x86.sse41.packusdw(<4 x i32> poison, <4 x i32> poison)
2121
ret <8 x i16> %1
2222
}
2323

2424
define <16 x i8> @poison_packsswb_128() {
2525
; CHECK-LABEL: @poison_packsswb_128(
26-
; CHECK-NEXT: ret <16 x i8> undef
26+
; CHECK-NEXT: ret <16 x i8> poison
2727
;
2828
%1 = call <16 x i8> @llvm.x86.sse2.packsswb.128(<8 x i16> poison, <8 x i16> poison)
2929
ret <16 x i8> %1
3030
}
3131

3232
define <16 x i8> @poison_packuswb_128() {
3333
; CHECK-LABEL: @poison_packuswb_128(
34-
; CHECK-NEXT: ret <16 x i8> undef
34+
; CHECK-NEXT: ret <16 x i8> poison
3535
;
3636
%1 = call <16 x i8> @llvm.x86.sse2.packuswb.128(<8 x i16> poison, <8 x i16> poison)
3737
ret <16 x i8> %1
3838
}
3939

4040
define <16 x i16> @poison_packssdw_256() {
4141
; CHECK-LABEL: @poison_packssdw_256(
42-
; CHECK-NEXT: ret <16 x i16> undef
42+
; CHECK-NEXT: ret <16 x i16> poison
4343
;
4444
%1 = call <16 x i16> @llvm.x86.avx2.packssdw(<8 x i32> poison, <8 x i32> poison)
4545
ret <16 x i16> %1
4646
}
4747

4848
define <16 x i16> @poison_packusdw_256() {
4949
; CHECK-LABEL: @poison_packusdw_256(
50-
; CHECK-NEXT: ret <16 x i16> undef
50+
; CHECK-NEXT: ret <16 x i16> poison
5151
;
5252
%1 = call <16 x i16> @llvm.x86.avx2.packusdw(<8 x i32> poison, <8 x i32> poison)
5353
ret <16 x i16> %1
5454
}
5555

5656
define <32 x i8> @poison_packsswb_256() {
5757
; CHECK-LABEL: @poison_packsswb_256(
58-
; CHECK-NEXT: ret <32 x i8> undef
58+
; CHECK-NEXT: ret <32 x i8> poison
5959
;
6060
%1 = call <32 x i8> @llvm.x86.avx2.packsswb(<16 x i16> poison, <16 x i16> poison)
6161
ret <32 x i8> %1
6262
}
6363

6464
define <32 x i8> @poison_packuswb_256() {
6565
; CHECK-LABEL: @poison_packuswb_256(
66-
; CHECK-NEXT: ret <32 x i8> undef
66+
; CHECK-NEXT: ret <32 x i8> poison
6767
;
6868
%1 = call <32 x i8> @llvm.x86.avx2.packuswb(<16 x i16> poison, <16 x i16> poison)
6969
ret <32 x i8> %1
7070
}
7171

7272
define <32 x i16> @poison_packssdw_512() {
7373
; CHECK-LABEL: @poison_packssdw_512(
74-
; CHECK-NEXT: ret <32 x i16> undef
74+
; CHECK-NEXT: ret <32 x i16> poison
7575
;
7676
%1 = call <32 x i16> @llvm.x86.avx512.packssdw.512(<16 x i32> poison, <16 x i32> poison)
7777
ret <32 x i16> %1
7878
}
7979

8080
define <32 x i16> @poison_packusdw_512() {
8181
; CHECK-LABEL: @poison_packusdw_512(
82-
; CHECK-NEXT: ret <32 x i16> undef
82+
; CHECK-NEXT: ret <32 x i16> poison
8383
;
8484
%1 = call <32 x i16> @llvm.x86.avx512.packusdw.512(<16 x i32> poison, <16 x i32> poison)
8585
ret <32 x i16> %1
8686
}
8787

8888
define <64 x i8> @poison_packsswb_512() {
8989
; CHECK-LABEL: @poison_packsswb_512(
90-
; CHECK-NEXT: ret <64 x i8> undef
90+
; CHECK-NEXT: ret <64 x i8> poison
9191
;
9292
%1 = call <64 x i8> @llvm.x86.avx512.packsswb.512(<32 x i16> poison, <32 x i16> poison)
9393
ret <64 x i8> %1
9494
}
9595

9696
define <64 x i8> @poison_packuswb_512() {
9797
; CHECK-LABEL: @poison_packuswb_512(
98-
; CHECK-NEXT: ret <64 x i8> undef
98+
; CHECK-NEXT: ret <64 x i8> poison
9999
;
100100
%1 = call <64 x i8> @llvm.x86.avx512.packuswb.512(<32 x i16> poison, <32 x i16> poison)
101101
ret <64 x i8> %1

llvm/test/Transforms/InstCombine/X86/x86-pshufb-inseltpoison.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,23 +446,23 @@ define <64 x i8> @fold_with_poison_elts_avx512(<64 x i8> %InVec) {
446446

447447
define <16 x i8> @fold_with_allpoison_elts(<16 x i8> %InVec) {
448448
; CHECK-LABEL: @fold_with_allpoison_elts(
449-
; CHECK-NEXT: ret <16 x i8> undef
449+
; CHECK-NEXT: ret <16 x i8> poison
450450
;
451451
%1 = tail call <16 x i8> @llvm.x86.ssse3.pshuf.b.128(<16 x i8> %InVec, <16 x i8> poison)
452452
ret <16 x i8> %1
453453
}
454454

455455
define <32 x i8> @fold_with_allpoison_elts_avx2(<32 x i8> %InVec) {
456456
; CHECK-LABEL: @fold_with_allpoison_elts_avx2(
457-
; CHECK-NEXT: ret <32 x i8> undef
457+
; CHECK-NEXT: ret <32 x i8> poison
458458
;
459459
%1 = tail call <32 x i8> @llvm.x86.avx2.pshuf.b(<32 x i8> %InVec, <32 x i8> poison)
460460
ret <32 x i8> %1
461461
}
462462

463463
define <64 x i8> @fold_with_allpoison_elts_avx512(<64 x i8> %InVec) {
464464
; CHECK-LABEL: @fold_with_allpoison_elts_avx512(
465-
; CHECK-NEXT: ret <64 x i8> undef
465+
; CHECK-NEXT: ret <64 x i8> poison
466466
;
467467
%1 = tail call <64 x i8> @llvm.x86.avx512.pshuf.b.512(<64 x i8> %InVec, <64 x i8> poison)
468468
ret <64 x i8> %1

llvm/test/Transforms/InstCombine/X86/x86-sse4a-inseltpoison.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ define <2 x i64> @test_extrq_args01(<2 x i64> %x, <16 x i8> %y) {
322322

323323
define <2 x i64> @test_extrq_ret(<2 x i64> %x, <16 x i8> %y) {
324324
; CHECK-LABEL: @test_extrq_ret(
325-
; CHECK-NEXT: ret <2 x i64> undef
325+
; CHECK-NEXT: ret <2 x i64> poison
326326
;
327327
%1 = tail call <2 x i64> @llvm.x86.sse4a.extrq(<2 x i64> %x, <16 x i8> %y) nounwind
328328
%2 = shufflevector <2 x i64> %1, <2 x i64> poison, <2 x i32> <i32 1, i32 1>
@@ -341,7 +341,7 @@ define <2 x i64> @test_extrqi_arg0(<2 x i64> %x) {
341341

342342
define <2 x i64> @test_extrqi_ret(<2 x i64> %x) {
343343
; CHECK-LABEL: @test_extrqi_ret(
344-
; CHECK-NEXT: ret <2 x i64> undef
344+
; CHECK-NEXT: ret <2 x i64> poison
345345
;
346346
%1 = tail call <2 x i64> @llvm.x86.sse4a.extrqi(<2 x i64> %x, i8 3, i8 2) nounwind
347347
%2 = shufflevector <2 x i64> %1, <2 x i64> poison, <2 x i32> <i32 1, i32 1>
@@ -360,7 +360,7 @@ define <2 x i64> @test_insertq_arg0(<2 x i64> %x, <2 x i64> %y) {
360360

361361
define <2 x i64> @test_insertq_ret(<2 x i64> %x, <2 x i64> %y) {
362362
; CHECK-LABEL: @test_insertq_ret(
363-
; CHECK-NEXT: ret <2 x i64> undef
363+
; CHECK-NEXT: ret <2 x i64> poison
364364
;
365365
%1 = tail call <2 x i64> @llvm.x86.sse4a.insertq(<2 x i64> %x, <2 x i64> %y) nounwind
366366
%2 = shufflevector <2 x i64> %1, <2 x i64> poison, <2 x i32> <i32 1, i32 1>
@@ -400,7 +400,7 @@ define <2 x i64> @test_insertqi_args01(<2 x i64> %x, <2 x i64> %y) {
400400

401401
define <2 x i64> @test_insertqi_ret(<2 x i64> %x, <2 x i64> %y) {
402402
; CHECK-LABEL: @test_insertqi_ret(
403-
; CHECK-NEXT: ret <2 x i64> undef
403+
; CHECK-NEXT: ret <2 x i64> poison
404404
;
405405
%1 = tail call <2 x i64> @llvm.x86.sse4a.insertqi(<2 x i64> %x, <2 x i64> %y, i8 3, i8 2) nounwind
406406
%2 = shufflevector <2 x i64> %1, <2 x i64> poison, <2 x i32> <i32 1, i32 1>

llvm/test/Transforms/InstCombine/X86/x86-sse4a.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ define <2 x i64> @test_extrq_args01(<2 x i64> %x, <16 x i8> %y) {
322322

323323
define <2 x i64> @test_extrq_ret(<2 x i64> %x, <16 x i8> %y) {
324324
; CHECK-LABEL: @test_extrq_ret(
325-
; CHECK-NEXT: ret <2 x i64> undef
325+
; CHECK-NEXT: ret <2 x i64> poison
326326
;
327327
%1 = tail call <2 x i64> @llvm.x86.sse4a.extrq(<2 x i64> %x, <16 x i8> %y) nounwind
328328
%2 = shufflevector <2 x i64> %1, <2 x i64> undef, <2 x i32> <i32 1, i32 1>
@@ -341,7 +341,7 @@ define <2 x i64> @test_extrqi_arg0(<2 x i64> %x) {
341341

342342
define <2 x i64> @test_extrqi_ret(<2 x i64> %x) {
343343
; CHECK-LABEL: @test_extrqi_ret(
344-
; CHECK-NEXT: ret <2 x i64> undef
344+
; CHECK-NEXT: ret <2 x i64> poison
345345
;
346346
%1 = tail call <2 x i64> @llvm.x86.sse4a.extrqi(<2 x i64> %x, i8 3, i8 2) nounwind
347347
%2 = shufflevector <2 x i64> %1, <2 x i64> undef, <2 x i32> <i32 1, i32 1>
@@ -360,7 +360,7 @@ define <2 x i64> @test_insertq_arg0(<2 x i64> %x, <2 x i64> %y) {
360360

361361
define <2 x i64> @test_insertq_ret(<2 x i64> %x, <2 x i64> %y) {
362362
; CHECK-LABEL: @test_insertq_ret(
363-
; CHECK-NEXT: ret <2 x i64> undef
363+
; CHECK-NEXT: ret <2 x i64> poison
364364
;
365365
%1 = tail call <2 x i64> @llvm.x86.sse4a.insertq(<2 x i64> %x, <2 x i64> %y) nounwind
366366
%2 = shufflevector <2 x i64> %1, <2 x i64> undef, <2 x i32> <i32 1, i32 1>
@@ -400,7 +400,7 @@ define <2 x i64> @test_insertqi_args01(<2 x i64> %x, <2 x i64> %y) {
400400

401401
define <2 x i64> @test_insertqi_ret(<2 x i64> %x, <2 x i64> %y) {
402402
; CHECK-LABEL: @test_insertqi_ret(
403-
; CHECK-NEXT: ret <2 x i64> undef
403+
; CHECK-NEXT: ret <2 x i64> poison
404404
;
405405
%1 = tail call <2 x i64> @llvm.x86.sse4a.insertqi(<2 x i64> %x, <2 x i64> %y, i8 3, i8 2) nounwind
406406
%2 = shufflevector <2 x i64> %1, <2 x i64> undef, <2 x i32> <i32 1, i32 1>

llvm/test/Transforms/InstCombine/vec_demanded_elts-inseltpoison.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ define <2 x i64> @PR24922(<2 x i64> %v) {
145145

146146
define <4 x float> @inselt_shuf_no_demand(float %a1, float %a2, float %a3) {
147147
; CHECK-LABEL: @inselt_shuf_no_demand(
148-
; CHECK-NEXT: ret <4 x float> undef
148+
; CHECK-NEXT: ret <4 x float> poison
149149
;
150150
%out1 = insertelement <4 x float> poison, float %a1, i32 1
151151
%out12 = insertelement <4 x float> %out1, float %a2, i32 2
@@ -158,7 +158,7 @@ define <4 x float> @inselt_shuf_no_demand(float %a1, float %a2, float %a3) {
158158

159159
define <4 x float> @inselt_shuf_no_demand_commute(float %a1, float %a2, float %a3) {
160160
; CHECK-LABEL: @inselt_shuf_no_demand_commute(
161-
; CHECK-NEXT: ret <4 x float> undef
161+
; CHECK-NEXT: ret <4 x float> poison
162162
;
163163
%out1 = insertelement <4 x float> poison, float %a1, i32 1
164164
%out12 = insertelement <4 x float> %out1, float %a2, i32 2
@@ -627,7 +627,7 @@ define <2 x ptr> @gep_all_lanes_undef(ptr %base, i64 %idx) {;
627627

628628
define ptr @gep_demanded_lane_undef(ptr %base, i64 %idx) {
629629
; CHECK-LABEL: @gep_demanded_lane_undef(
630-
; CHECK-NEXT: ret ptr undef
630+
; CHECK-NEXT: ret ptr poison
631631
;
632632
%basevec = insertelement <2 x ptr> poison, ptr %base, i32 0
633633
%idxvec = insertelement <2 x i64> poison, i64 %idx, i32 1

0 commit comments

Comments
 (0)