[PATCH] Canonicalize addrspacecast between different pointer types.

Matt Arsenault arsenm2 at gmail.com
Sun Nov 17 18:05:38 PST 2013

On Nov 17, 2013, at 5:12 AM, Michele Scandale <michele.scandale at gmail.com> wrote:

>  I would like to better understand the motivation of this patch: what are the benefit obtained doing a split between the change of address space and the pointer type within the new address space?
>  Being a bitcast just a reintepretation of the input value (no change in the bits) this behavior has been included in the addrspacecast instruction (nobody reported any objection on this).

The addrspacecast instruction’s purpose is to only change the address space. Changing the type of the pointer is a logically separate operation. If separated out, the bitcast could potentially be combined with other instructions that use the value to simplify things. This is similar to how inttoptr / ptrtoint behave. You can use a different size integer than the pointer size, but instcombine splits it into the 2 logically steps of reinterpreting as an integer, and then extending or truncating to the real pointer size.

More information about the llvm-commits mailing list