[PATCH] D37832: Eliminate PHI (int typed) which is only used by inttoptr

Nuno Lopes via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 20 03:56:36 PDT 2017


nlopes added a comment.

In https://reviews.llvm.org/D37832#875262, @davidxl wrote:

> As I have mentioned, this patch itself does *not* fold any ptrtoint/inttoptr. It simply moves the intptr across the phi node. The folding you see with the test cases  is done by existing optimizations, so I am not sure what the objection is about.


Ok, to be precise the patch does the following:
v = phi(ptr2int(p), ptr2int(q))
 =>
v = bitcast(phi(p, q) to int)

This transformation by itself is not correct in all cases. Ptr2int is not a NOP.
Also, it makes me really uneasy the fact that the test cases provided take advantage of a broken optimization. Since it's not possible to test the new transformation in isolation, all I see is an end-to-end incorrect transformation (even if the proposed transformation was fully correct, which is not).


https://reviews.llvm.org/D37832





More information about the llvm-commits mailing list