From 5d143aa0f3ac0a67ee4f3c79e2567632ef21bc5d Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Wed, 3 Apr 2019 13:30:14 +0100 Subject: [PATCH] SpirvShader: Ignore unreachable inputs for Phis. Bug: b/128527271 Change-Id: I4bf01e7915735d7fd3dc827fd67873fff75a756f Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28354 Presubmit-Ready: Ben Clayton Reviewed-by: Nicolas Capens Kokoro-Presubmit: kokoro Tested-by: Ben Clayton --- src/Pipeline/SpirvShader.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Pipeline/SpirvShader.cpp b/src/Pipeline/SpirvShader.cpp index 2106bdc7d..9a706aff7 100644 --- a/src/Pipeline/SpirvShader.cpp +++ b/src/Pipeline/SpirvShader.cpp @@ -1373,6 +1373,12 @@ namespace sw { auto varId = Object::ID(insn.word(w + 0)); auto blockId = Block::ID(insn.word(w + 1)); + + if (block.ins.count(blockId) == 0) + { + continue; // In is unreachable. Ignore. + } + if (existsPath(state->currentBlock, blockId, block.mergeBlock)) { // This source is from a loop back-edge. @@ -3028,6 +3034,7 @@ namespace sw auto typeId = Type::ID(insn.word(1)); auto type = getType(typeId); auto objectId = Object::ID(insn.word(2)); + auto currentBlock = getBlock(state->currentBlock); auto tmp = std::unique_ptr(new SIMD::Int[type.sizeInComponents]); @@ -3037,6 +3044,11 @@ namespace sw auto varId = Object::ID(insn.word(w + 0)); auto blockId = Block::ID(insn.word(w + 1)); + if (currentBlock.ins.count(blockId) == 0) + { + continue; // In is unreachable. Ignore. + } + auto in = GenericValue(this, routine, varId); auto mask = GetActiveLaneMaskEdge(state, blockId, state->currentBlock); -- 2.11.0