llvm-project
de9e18dc - [InstCombine] Handle ptrtoaddr in gep of pointer sub fold (#164818)

Commit
179 days ago
[InstCombine] Handle ptrtoaddr in gep of pointer sub fold (#164818) This extends the `ptradd x, ptrtoint(y) - ptrtoint(x)` to `y` InstCombine fold to support ptrtoaddr. In the case where x and y have the same underlying object, this is handled by InstSimplify already. If the underlying object may differ, the replacement can only be performed if provenance does not matter. For pointers with non-address bits we need to be careful here, because the pattern will return a pointer with the non-address bits of x and the address bits of y. As such, uses in ptrtoaddr are safe to replace, but uses in ptrtoint are not. Whether uses in icmp are safe to replace depends on the outcome of the pending discussion on icmp semantics (I'll adjust this in https://github.com/llvm/llvm-project/pull/163936 if/when that lands).
Author
Parents
Loading