diff options
author | Jason Ekstrand <[email protected]> | 2015-05-08 09:48:33 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-05-08 17:29:15 -0700 |
commit | fb5f411248d9c342ed249228f7dac713dcfd3d06 (patch) | |
tree | 7d1849d20b49a158baed3434e1d041c7bf186043 /src/glsl/nir | |
parent | e0cfe59c37245d8555202a12b9b29866894d6d18 (diff) |
nir/search: Save/restore the variables_seen bitmask when matching
Shader-db results on Broadwell:
total instructions in shared programs: 7152330 -> 7137006 (-0.21%)
instructions in affected programs: 1330548 -> 1315224 (-1.15%)
helped: 5797
HURT: 76
GAINED: 0
LOST: 8
Reviewed-by: Connor Abbott <[email protected]>
Diffstat (limited to 'src/glsl/nir')
-rw-r--r-- | src/glsl/nir/nir_search.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/glsl/nir/nir_search.c b/src/glsl/nir/nir_search.c index 1c171f2a729..0c4e48ce965 100644 --- a/src/glsl/nir/nir_search.c +++ b/src/glsl/nir/nir_search.c @@ -207,6 +207,11 @@ match_expression(const nir_search_expression *expr, nir_alu_instr *instr, } } + /* Stash off the current variables_seen bitmask. This way we can + * restore it prior to matching in the commutative case below. + */ + unsigned variables_seen_stash = state->variables_seen; + bool matched = true; for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++) { if (!match_value(expr->srcs[i], instr, i, num_components, @@ -221,6 +226,13 @@ match_expression(const nir_search_expression *expr, nir_alu_instr *instr, if (nir_op_infos[instr->op].algebraic_properties & NIR_OP_IS_COMMUTATIVE) { assert(nir_op_infos[instr->op].num_inputs == 2); + + /* Restore the variables_seen bitmask. If we don't do this, then we + * could end up with an erroneous failure due to variables found in the + * first match attempt above not matching those in the second. + */ + state->variables_seen = variables_seen_stash; + if (!match_value(expr->srcs[0], instr, 1, num_components, swizzle, state)) return false; |