[PATCH] D72492: GlobalISel: Implement lower for G_BITCAST

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 10 10:59:56 PST 2020


arsenm added a comment.

In D72492#1814681 <https://reviews.llvm.org/D72492#1814681>, @aemerson wrote:

> In D72492#1814675 <https://reviews.llvm.org/D72492#1814675>, @arsenm wrote:
>
> > In D72492#1814575 <https://reviews.llvm.org/D72492#1814575>, @arsenm wrote:
> >
> > > In D72492#1814528 <https://reviews.llvm.org/D72492#1814528>, @aemerson wrote:
> > >
> > > > On AArch64 we also use bitcast to convert from <n x p0> to <n x s64> types.
> > >
> > >
> > > I thought that was illegal. It’s not legal in IR
> >
> >
> > I think this is a verifier bug. You're not allowed to bitcast between scalar pointers and scalars, so allowing it for vectors doesn't make much sense.  I think allowing this is potentially problematic for non-integral pointers since it makes it easy to accidentally launder away the pointerness
>
>
> We don't have an alternative way to easily convert between them though. Unless G_PTRTOINT is also allowed to take vectors of pointers.


G_PTRTOINT works with vectors. I'm not opposed to allowing G_BITCAST between scalar and (integral) pointers, although this differs from the IR. It makes more sense in codegen to have these be more flexible. The current state doesn't make sense though. We can either:

1. Allow casts between pointers and others types. This will need documenting as differing from the corresponding IR instructions. This should also maybe restrict this for nonintegral address spaces?



1. Disallow bitcast between vectors of pointers and vectors of scalars and match the IR




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

https://reviews.llvm.org/D72492





More information about the llvm-commits mailing list