[PATCH] D136882: ConstantFold: Fold out compare of addrspacecasted null with global

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 28 06:54:37 PDT 2022


nhaehnle added a comment.

In D136882#3891143 <https://reviews.llvm.org/D136882#3891143>, @nikic wrote:

> I'm not completely convinced that this is correct. Note that `icmp` on pointers is a pure bitwise comparison, it is not affected by provenance. I think it's pretty clear that `ptr null` and `ptr addrspace(3) @lds` are distinct underlying objects, with distinct provenance, and that's all that matters to alias analysis. But it's less obvious to me that casting `ptr null` to `ptr addrspace(3)` may not produce a bit pattern that just so happens to match `ptr addrspace(3) @lds`.

In the issue discussion, I hadn't considered the fact that `icmp` is a pure bitwise comparison. This convinces me that the fold is incorrect without target-specific information.

It is correct for this particular case with target-specific information.


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

https://reviews.llvm.org/D136882



More information about the llvm-commits mailing list