[PATCH] D151587: [clang][ConstantEmitter] have tryEmitPrivate[ForVarInit] try ConstExprEmitter fast-path first

Eli Friedman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 26 10:31:43 PDT 2023


efriedma added inline comments.


================
Comment at: clang/test/CodeGenOpenCL/amdgpu-nullptr.cl:60
 
-// CHECK: @fold_priv ={{.*}} local_unnamed_addr addrspace(1) global ptr addrspace(5) addrspacecast (ptr null to ptr addrspace(5)), align 4
+// CHECK: @fold_priv ={{.*}} local_unnamed_addr addrspace(1) global ptr addrspace(5) addrspacecast (ptr addrspace(1) null to ptr addrspace(5)), align 4
 private short *fold_priv = (private short*)(generic int*)(global void*)0;
----------------
arsenm wrote:
> This should have stayed a cast from generic, 1->5 cast isn't defined
If it's not supposed to behave this way, it's a bug in LLVM constant folding; the following folds the same way if you pass it to `opt -S`.  Given that, I don't think it should block this patch.  (I think the relevant code is CastInst::isEliminableCastPair.)

```
target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8"
target triple = "amdgcn"
@fold_priv = local_unnamed_addr addrspace(1) global ptr addrspace(5) addrspacecast (ptr addrspacecast(ptr addrspace(1) null to ptr) to ptr addrspace(5)), align 4
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151587



More information about the cfe-commits mailing list