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

Nuno Lopes via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 28 02:19:40 PDT 2022


nlopes added a subscriber: regehr.
nlopes 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`.
>
> @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?

Indeed, everything gets written to stdout (long story, but it allows us to forward all output to a file; we could have 2 pipes ofc, but..).
@regehr It seems that there might be some regex stuff going on to cleanup the output that is filtering out the errors? Or maybe CE just does that by default when the command fails?

Regarding the optimization itself, doesn't look correct to me either, for the exact reason that Nikita gave.


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

https://reviews.llvm.org/D136882



More information about the llvm-commits mailing list