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

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 28 01:41:53 PDT 2022


nikic added a subscriber: nlopes.
nikic added a comment.

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`.

@nlopes This silently fails to compile in the online version: https://alive2.llvm.org/ce/z/XC2RGM Locally it prints:

  ERROR: Unsupported instruction:   %__constexpr_0 = icmp eq ptr addrspace(3) addrspacecast (ptr null to ptr addrspace(3)), @lds
  ERROR: Unsupported instruction:   ret i1 icmp eq (ptr addrspace(3) addrspacecast (ptr null to ptr addrspace(3)), ptr addrspace(3) @lds)
  ERROR: Could not translate 'src' to Alive IR

Would be great if these errors would show up online as well. Maybe the problem is that the error gets printed to stdout rather than stderr?


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

https://reviews.llvm.org/D136882



More information about the llvm-commits mailing list