Bug P2
Status Update
Comments
ap...@google.com <ap...@google.com> #2
Project: SwiftShader
Branch: master
commit d6dd61cbc210a9c121b0f3a11a0f4f96f6e3a81a
Author: Alexis Hetu <sugoi@google.com>
Date: Thu Jun 16 16:51:23 2022
Allow subzero to cast pointers to integer types
A new CL:
https://swiftshader-review.googlesource.com/c/SwiftShader/+/66457
enabled casting pointers to integer types, which works with LLVM,
but not with Subzero. This CL turns on the emulated path for
Subzero in that case in order to make the conversion code work.
Bug: b/236387999
Change-Id: I7d2dfa91ac41ba5c9cd19d67f44e4896604367f4
Reviewed-on:https://swiftshader-review.googlesource.com/c/SwiftShader/+/66528
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
M src/Reactor/SubzeroReactor.cpp
https://swiftshader-review.googlesource.com/66528
Branch: master
commit d6dd61cbc210a9c121b0f3a11a0f4f96f6e3a81a
Author: Alexis Hetu <sugoi@google.com>
Date: Thu Jun 16 16:51:23 2022
Allow subzero to cast pointers to integer types
A new CL:
enabled casting pointers to integer types, which works with LLVM,
but not with Subzero. This CL turns on the emulated path for
Subzero in that case in order to make the conversion code work.
Bug:
Change-Id: I7d2dfa91ac41ba5c9cd19d67f44e4896604367f4
Reviewed-on:
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
M src/Reactor/SubzeroReactor.cpp
ni...@google.com <ni...@google.com> #3
As noted Int2
into a 64-bit pointer. It might be straightforward to also support the inverse cast at the Subzero level, and revert the
Description
LLVM's instruction is specified to only support casting pointers to/from other pointers. One must use to cast them to/from integers. In practice we've found
bitcast
ptrtoint
andinttoptr
bitcast
to support these casts as well, but this might be highly target-specific and should be avoided. That said, it's worth noting that C++'sreinterpret_cast<>
has this flexibility as well, and Reactor'sAs<>
currently has no explicit restriction other than the sizes must match.That said, we had to add support for casting 'emulated' vectors and casting scalars to vectors .
For SPIR-V's instruction we need support for casting between 64-bit pointers and int2 vectors. This happens to already work for the LLVM backend, but Subzero only supports casting between vectors and 32-bit values.
OpBitcast
We should check support for all combinations for both backends, add unit tests, comply with LLVM's restrictions, and where necessary optimizing things. For example Subzero could use
movq
for 64-bit values, similar to its use ofmovd
for 32-bit values, instead of storing to memory and loading from it again.