[llvm] [GVN] Restrict equality propagation for pointers (PR #82458)

Nuno Lopes via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 26 08:27:18 PST 2024


nunoplopes wrote:

Essentially this patch allows replacement of pointers in this situation:
```
if (p == q) {
  use(p);
}
```

Where `use(p)` is any of `icmp` or `ptrtoint`.
This is correct because these users only care about the pointer address not its provenance.
I'm not super familiar with GVN's code (only NewGVN), but the patch looks good to me.

For a follow up patch, another condition that can be considered is if both `p` and `q` are dereferenceable. That guarantees that the remaining uses (load, store, etc) can see either of the pointers.

https://github.com/llvm/llvm-project/pull/82458


More information about the llvm-commits mailing list