Skip to content

Commit bd6f2f2

Browse files
committed
Only propagate if both inputs poison
1 parent 2284667 commit bd6f2f2

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,8 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
719719
Value *Src0 = II.getArgOperand(0);
720720
Value *Src1 = II.getArgOperand(1);
721721

722-
if (isa<PoisonValue>(Src0) || isa<PoisonValue>(Src1))
722+
// TODO: Replace call with scalar operation if only one element is poison.
723+
if (isa<PoisonValue>(Src0) && isa<PoisonValue>(Src1))
723724
return IC.replaceInstUsesWith(II, PoisonValue::get(II.getType()));
724725

725726
if (isa<UndefValue>(Src0) && isa<UndefValue>(Src1)) {

llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,15 +1322,17 @@ define <2 x i16> @undef_cvt_pknorm_i16() {
13221322

13231323
define <2 x i16> @poison_lhs_cvt_pknorm_i16(float %y) {
13241324
; CHECK-LABEL: @poison_lhs_cvt_pknorm_i16(
1325-
; CHECK-NEXT: ret <2 x i16> poison
1325+
; CHECK-NEXT: [[CVT:%.*]] = call <2 x i16> @llvm.amdgcn.cvt.pknorm.i16(float poison, float [[Y:%.*]])
1326+
; CHECK-NEXT: ret <2 x i16> [[CVT]]
13261327
;
13271328
%cvt = call <2 x i16> @llvm.amdgcn.cvt.pknorm.i16(float poison, float %y)
13281329
ret <2 x i16> %cvt
13291330
}
13301331

13311332
define <2 x i16> @poison_rhs_cvt_pknorm_i16(float %x) {
13321333
; CHECK-LABEL: @poison_rhs_cvt_pknorm_i16(
1333-
; CHECK-NEXT: ret <2 x i16> poison
1334+
; CHECK-NEXT: [[CVT:%.*]] = call <2 x i16> @llvm.amdgcn.cvt.pknorm.i16(float [[X:%.*]], float poison)
1335+
; CHECK-NEXT: ret <2 x i16> [[CVT]]
13341336
;
13351337
%cvt = call <2 x i16> @llvm.amdgcn.cvt.pknorm.i16(float %x, float poison)
13361338
ret <2 x i16> %cvt
@@ -1378,15 +1380,17 @@ define <2 x i16> @undef_cvt_pknorm_u16() {
13781380

13791381
define <2 x i16> @poison_lhs_cvt_pknorm_u16(float %y) {
13801382
; CHECK-LABEL: @poison_lhs_cvt_pknorm_u16(
1381-
; CHECK-NEXT: ret <2 x i16> poison
1383+
; CHECK-NEXT: [[CVT:%.*]] = call <2 x i16> @llvm.amdgcn.cvt.pknorm.u16(float poison, float [[Y:%.*]])
1384+
; CHECK-NEXT: ret <2 x i16> [[CVT]]
13821385
;
13831386
%cvt = call <2 x i16> @llvm.amdgcn.cvt.pknorm.u16(float poison, float %y)
13841387
ret <2 x i16> %cvt
13851388
}
13861389

13871390
define <2 x i16> @poison_rhs_cvt_pknorm_u16(float %x) {
13881391
; CHECK-LABEL: @poison_rhs_cvt_pknorm_u16(
1389-
; CHECK-NEXT: ret <2 x i16> poison
1392+
; CHECK-NEXT: [[CVT:%.*]] = call <2 x i16> @llvm.amdgcn.cvt.pknorm.u16(float [[X:%.*]], float poison)
1393+
; CHECK-NEXT: ret <2 x i16> [[CVT]]
13901394
;
13911395
%cvt = call <2 x i16> @llvm.amdgcn.cvt.pknorm.u16(float %x, float poison)
13921396
ret <2 x i16> %cvt
@@ -1434,15 +1438,17 @@ define <2 x i16> @undef_cvt_pk_i16() {
14341438

14351439
define <2 x i16> @poison_lhs_cvt_pk_i16(i32 %y) {
14361440
; CHECK-LABEL: @poison_lhs_cvt_pk_i16(
1437-
; CHECK-NEXT: ret <2 x i16> poison
1441+
; CHECK-NEXT: [[CVT:%.*]] = call <2 x i16> @llvm.amdgcn.cvt.pk.i16(i32 poison, i32 [[Y:%.*]])
1442+
; CHECK-NEXT: ret <2 x i16> [[CVT]]
14381443
;
14391444
%cvt = call <2 x i16> @llvm.amdgcn.cvt.pk.i16(i32 poison, i32 %y)
14401445
ret <2 x i16> %cvt
14411446
}
14421447

14431448
define <2 x i16> @poison_rhs_cvt_pk_i16(i32 %x) {
14441449
; CHECK-LABEL: @poison_rhs_cvt_pk_i16(
1445-
; CHECK-NEXT: ret <2 x i16> poison
1450+
; CHECK-NEXT: [[CVT:%.*]] = call <2 x i16> @llvm.amdgcn.cvt.pk.i16(i32 [[X:%.*]], i32 poison)
1451+
; CHECK-NEXT: ret <2 x i16> [[CVT]]
14461452
;
14471453
%cvt = call <2 x i16> @llvm.amdgcn.cvt.pk.i16(i32 %x, i32 poison)
14481454
ret <2 x i16> %cvt
@@ -1490,15 +1496,17 @@ define <2 x i16> @undef_cvt_pk_u16() {
14901496

14911497
define <2 x i16> @poison_lhs_cvt_pk_u16(i32 %y) {
14921498
; CHECK-LABEL: @poison_lhs_cvt_pk_u16(
1493-
; CHECK-NEXT: ret <2 x i16> poison
1499+
; CHECK-NEXT: [[CVT:%.*]] = call <2 x i16> @llvm.amdgcn.cvt.pk.u16(i32 poison, i32 [[Y:%.*]])
1500+
; CHECK-NEXT: ret <2 x i16> [[CVT]]
14941501
;
14951502
%cvt = call <2 x i16> @llvm.amdgcn.cvt.pk.u16(i32 poison, i32 %y)
14961503
ret <2 x i16> %cvt
14971504
}
14981505

14991506
define <2 x i16> @poison_rhs_cvt_pk_u16(i32 %x) {
15001507
; CHECK-LABEL: @poison_rhs_cvt_pk_u16(
1501-
; CHECK-NEXT: ret <2 x i16> poison
1508+
; CHECK-NEXT: [[CVT:%.*]] = call <2 x i16> @llvm.amdgcn.cvt.pk.u16(i32 [[X:%.*]], i32 poison)
1509+
; CHECK-NEXT: ret <2 x i16> [[CVT]]
15021510
;
15031511
%cvt = call <2 x i16> @llvm.amdgcn.cvt.pk.u16(i32 %x, i32 poison)
15041512
ret <2 x i16> %cvt

0 commit comments

Comments
 (0)