Index: llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp =================================================================== --- llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp +++ llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp @@ -460,14 +460,17 @@ return ⅈ } - // FIXME: Should propagate poison. - if (isa(Src0)) - return IC.replaceInstUsesWith(II, UndefValue::get(II.getType())); + // Propagate poison. + if (isa(Src0) || isa(Src1)) + IC.replaceInstUsesWith(II, PoisonValue::get(II.getType())); - if (isa(Src1)) { + // llvm.amdgcn.class(_, undef) -> false + if (IC.getSimplifyQuery().isUndefValue(Src1)) return IC.replaceInstUsesWith(II, ConstantInt::get(II.getType(), false)); - } + // llvm.amdgcn.class(undef, _) -> undef + if (IC.getSimplifyQuery().isUndefValue(Src0)) + return IC.replaceInstUsesWith(II, UndefValue::get(II.getType())); break; } case Intrinsic::amdgcn_cvt_pkrtz: { Index: llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll =================================================================== --- llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll +++ llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll @@ -569,14 +569,14 @@ define i1 @test_class_poison_poison_f32(float %x) nounwind { ; CHECK-LABEL: @test_class_poison_poison_f32( -; CHECK-NEXT: ret i1 undef +; CHECK-NEXT: ret i1 poison ; %val = call i1 @llvm.amdgcn.class.f32(float poison, i32 poison) ret i1 %val } define i1 @test_class_val_poison_f32(float %arg) nounwind { ; CHECK-LABEL: @test_class_val_poison_f32( -; CHECK-NEXT: ret i1 false +; CHECK-NEXT: ret i1 poison ; %val = call i1 @llvm.amdgcn.class.f32(float %arg, i32 poison) ret i1 %val @@ -584,7 +584,7 @@ define i1 @test_class_poison_val_f32(i32 %arg) nounwind { ; CHECK-LABEL: @test_class_poison_val_f32( -; CHECK-NEXT: ret i1 undef +; CHECK-NEXT: ret i1 poison ; %val = call i1 @llvm.amdgcn.class.f32(float poison, i32 %arg) ret i1 %val @@ -649,7 +649,7 @@ define i1 @test_class_undef_undef_f32() nounwind { ; CHECK-LABEL: @test_class_undef_undef_f32( -; CHECK-NEXT: ret i1 undef +; CHECK-NEXT: ret i1 false ; %val = call i1 @llvm.amdgcn.class.f32(float undef, i32 undef) ret i1 %val