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 ...@@ -1277,14 +1277,13 @@ namespace sw
if (blockId != mainBlockId) if (blockId != mainBlockId)
{ {
// Set the activeLaneMask. // Set the activeLaneMask.
Intermediate activeLaneMask(1); SIMD::Int activeLaneMask(0);
activeLaneMask.move(0, SIMD::Int(0));
for (auto in : block.ins) for (auto in : block.ins)
{ {
auto inMask = GetActiveLaneMaskEdge(state, in, blockId); 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); EmitInstructions(block.begin(), block.end(), state);
...@@ -3030,7 +3029,7 @@ namespace sw ...@@ -3030,7 +3029,7 @@ namespace sw
auto type = getType(typeId); auto type = getType(typeId);
auto objectId = Object::ID(insn.word(2)); 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; bool first = true;
for (uint32_t w = 3; w < insn.wordCount(); w += 2) for (uint32_t w = 3; w < insn.wordCount(); w += 2)
...@@ -3044,11 +3043,17 @@ namespace sw ...@@ -3044,11 +3043,17 @@ namespace sw
for (uint32_t i = 0; i < type.sizeInComponents; i++) for (uint32_t i = 0; i < type.sizeInComponents; i++)
{ {
auto inMasked = in.Int(i) & mask; auto inMasked = in.Int(i) & mask;
dst.replace(i, first ? inMasked : (dst.Int(i) | inMasked)); tmp[i] = first ? inMasked : (tmp[i] | inMasked);
} }
first = false; 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; return EmitResult::Continue;
} }
......
...@@ -86,14 +86,6 @@ namespace sw ...@@ -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::Int> &scalar) { emplace(i, scalar.value); }
void move(uint32_t i, const RValue<SIMD::UInt> &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. // Value retrieval functions.
RValue<SIMD::Float> Float(uint32_t i) const RValue<SIMD::Float> Float(uint32_t i) const
{ {
...@@ -130,12 +122,6 @@ namespace sw ...@@ -130,12 +122,6 @@ namespace sw
scalar[i] = value; scalar[i] = value;
} }
void replace(uint32_t i, rr::Value *value)
{
ASSERT(i < size);
scalar[i] = value;
}
rr::Value **const scalar; rr::Value **const scalar;
uint32_t size; 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