[PATCH] D115669: AMDGPU: Combine is.shared/is.private of null/undef

Stanislav Mekhanoshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 13 14:17:35 PST 2021


rampitec added inline comments.


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp:900
+
+    if (isa<ConstantPointerNull>(II.getArgOperand(0)))
+      return IC.replaceInstUsesWith(II, ConstantInt::getFalse(II.getType()));
----------------
rampitec wrote:
> arsenm wrote:
> > rampitec wrote:
> > > Why cannot we have a shared or private null pointer?
> > The query is for whether the particular address points into the aperture. The null pointer doesn't point at anything, so therefore it doesn't point into the shared/private segment
> You can have a flat pointer pointing exactly into the address zero of LDS or private. Aren't these addresses also null?
I believe this is not correct and clearly change in behavior:

```
define i1 @test(i32 addrspace(1)* %res) {
  %cast = addrspacecast i8 addrspace(5)* null to i8*
  %is_private = tail call i1 @llvm.amdgcn.is.private(i8* %cast)
  ret i1 %is_private
}

declare i1 @llvm.amdgcn.is.private(i8* nocapture)
```
Right now it is true:

```
        s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
        v_mov_b32_e32 v0, 1
        s_setpc_b64 s[30:31]
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115669/new/

https://reviews.llvm.org/D115669



More information about the llvm-commits mailing list