Commit 9abf32b0 by Ben Clayton

SpirvShader: Optimize SIMD loads of static, equal offsets, in-bound pointers

Bug: b/135609394 Change-Id: Ic566f2ef6d66e31b434d29b23aafd954a05958a4 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/33709Tested-by: 's avatarBen Clayton <bclayton@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 68cfc78e
......@@ -291,22 +291,29 @@ namespace sw
{
using EL = typename Element<T>::type;
if (ptr.hasStaticSequentialOffsets(sizeof(float)) &&
ptr.isStaticAllInBounds(sizeof(float)))
if (ptr.isStaticAllInBounds(sizeof(float)))
{
// All elements sequential and in bounds.
// Perform regular load.
auto load = rr::Load(rr::Pointer<SIMD::Int>(ptr.base + ptr.staticOffsets[0]), alignment, atomic, order);
return As<T>(load & mask); // TODO: Mask here should be unnecessary, but keeps with MaskedLoad and Gather.
}
auto offsets = ptr.offsets();
// All elements are statically known to be in-bounds.
// We can avoid costly conditional on masks.
if(robust) // Disable OOB reads.
if (ptr.hasStaticSequentialOffsets(sizeof(float)))
{
// Offsets are sequential. Perform regular load.
return rr::Load(rr::Pointer<T>(ptr.base + ptr.staticOffsets[0]), alignment, atomic, order);
}
if (ptr.hasStaticEqualOffsets())
{
// Load one, replicate.
return T(*rr::Pointer<EL>(ptr.base + ptr.staticOffsets[0], alignment));
}
}
else if(robust) // Disable OOB reads.
{
mask &= ptr.isInBounds(sizeof(float));
}
auto offsets = ptr.offsets();
if (!atomic && order == std::memory_order_relaxed)
{
if (ptr.hasStaticEqualOffsets())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment