Skip to content

Commit e7c2c80

Browse files
authored
[AMDGPU] Combine prng(undef) -> undef (#154160)
1 parent 1bb7217 commit e7c2c80

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4002,7 +4002,8 @@ SDValue AMDGPUTargetLowering::performIntrinsicWOChainCombine(
40024002
case Intrinsic::amdgcn_rcp_legacy:
40034003
case Intrinsic::amdgcn_rsq_legacy:
40044004
case Intrinsic::amdgcn_rsq_clamp:
4005-
case Intrinsic::amdgcn_tanh: {
4005+
case Intrinsic::amdgcn_tanh:
4006+
case Intrinsic::amdgcn_prng_b32: {
40064007
// FIXME: This is probably wrong. If src is an sNaN, it won't be quieted
40074008
SDValue Src = N->getOperand(1);
40084009
return Src.isUndef() ? Src : SDValue();

llvm/test/CodeGen/AMDGPU/llvm.amdgcn.prng.ll

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; RUN: llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx950 < %s | FileCheck -check-prefixes=GCN %s
22
; RUN: llc -global-isel=1 -mtriple=amdgcn -mcpu=gfx950 < %s | FileCheck -check-prefix=GCN %s
3-
; RUN: llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx1250 < %s | FileCheck -check-prefixes=GCN %s
3+
; RUN: llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx1250 < %s | FileCheck -check-prefixes=GCN,SDAG %s
44
; RUN: llc -global-isel=1 -mtriple=amdgcn -mcpu=gfx1250 < %s | FileCheck -check-prefix=GCN %s
55

66
declare i32 @llvm.amdgcn.prng.b32(i32) #0
@@ -29,6 +29,13 @@ define amdgpu_kernel void @prng_b32_constant_100(ptr addrspace(1) %out) #1 {
2929
ret void
3030
}
3131

32+
; GCN-LABEL: {{^}}prng_undef_i32:
33+
; SDAG-NOT: v_prng_b32
34+
define amdgpu_kernel void @prng_undef_i32(ptr addrspace(1) %out) #1 {
35+
%prng = call i32 @llvm.amdgcn.prng.b32(i32 undef)
36+
store i32 %prng, ptr addrspace(1) %out, align 4
37+
ret void
38+
}
3239

3340
attributes #0 = { nounwind readnone }
3441
attributes #1 = { nounwind }

0 commit comments

Comments
 (0)