Commit 459453a9 by Nicolas Capens Committed by Nicolas Capens

Eliminate Intermediate::replace()

With Reactor variables now merely tracking the last assigned rvalue if used within a single basic block, we can avoid the unsafe replace() operation on SpirvShader::Intermediate. This effectively reverts https://swiftshader-review.googlesource.com/c/SwiftShader/+/27769 Bug b/129356087 Bug b/128527271 Change-Id: Ibfafc6960ac7e10b898ff8804752b928a7fc1988 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28109Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarBen Clayton <bclayton@google.com>
parent 0192d15d
......@@ -1277,14 +1277,13 @@ namespace sw
if (blockId != mainBlockId)
{
// Set the activeLaneMask.
Intermediate activeLaneMask(1);
activeLaneMask.move(0, SIMD::Int(0));
SIMD::Int activeLaneMask(0);
for (auto in : block.ins)
{
auto inMask = GetActiveLaneMaskEdge(state, in, blockId);
activeLaneMask.replace(0, activeLaneMask.Int(0) | inMask);
activeLaneMask |= inMask;
}
state->setActiveLaneMask(activeLaneMask.Int(0));
state->setActiveLaneMask(activeLaneMask);
}
EmitInstructions(block.begin(), block.end(), state);
......@@ -3030,7 +3029,7 @@ namespace sw
auto type = getType(typeId);
auto objectId = Object::ID(insn.word(2));
auto &dst = routine->createIntermediate(objectId, type.sizeInComponents);
auto tmp = std::unique_ptr<SIMD::Int[]>(new SIMD::Int[type.sizeInComponents]);
bool first = true;
for (uint32_t w = 3; w < insn.wordCount(); w += 2)
......@@ -3044,11 +3043,17 @@ namespace sw
for (uint32_t i = 0; i < type.sizeInComponents; i++)
{
auto inMasked = in.Int(i) & mask;
dst.replace(i, first ? inMasked : (dst.Int(i) | inMasked));
tmp[i] = first ? inMasked : (tmp[i] | inMasked);
}
first = false;
}
auto &dst = routine->createIntermediate(objectId, type.sizeInComponents);
for(uint32_t i = 0; i < type.sizeInComponents; i++)
{
dst.move(i, tmp[i]);
}
return EmitResult::Continue;
}
......
......@@ -86,14 +86,6 @@ namespace sw
void move(uint32_t i, const RValue<SIMD::Int> &scalar) { emplace(i, scalar.value); }
void move(uint32_t i, const RValue<SIMD::UInt> &scalar) { emplace(i, scalar.value); }
void replace(uint32_t i, RValue<SIMD::Float> &&scalar) { replace(i, scalar.value); }
void replace(uint32_t i, RValue<SIMD::Int> &&scalar) { replace(i, scalar.value); }
void replace(uint32_t i, RValue<SIMD::UInt> &&scalar) { replace(i, scalar.value); }
void replace(uint32_t i, const RValue<SIMD::Float> &scalar) { replace(i, scalar.value); }
void replace(uint32_t i, const RValue<SIMD::Int> &scalar) { replace(i, scalar.value); }
void replace(uint32_t i, const RValue<SIMD::UInt> &scalar) { replace(i, scalar.value); }
// Value retrieval functions.
RValue<SIMD::Float> Float(uint32_t i) const
{
......@@ -130,12 +122,6 @@ namespace sw
scalar[i] = value;
}
void replace(uint32_t i, rr::Value *value)
{
ASSERT(i < size);
scalar[i] = value;
}
rr::Value **const scalar;
uint32_t size;
};
......
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