Mesa (master): nir/constant_folding: Use nir_src_as_bool for discard_if
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Oct 26 16:45:59 UTC 2018
Module: Mesa
Branch: master
Commit: 249e32ab17bdbe1f26449079b0eafd3391b52d0f
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=249e32ab17bdbe1f26449079b0eafd3391b52d0f
Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date: Mon Oct 22 15:53:14 2018 -0500
nir/constant_folding: Use nir_src_as_bool for discard_if
Missed one while converting to the nir_src_as_* helpers.
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Eric Anholt <eric at anholt.net>
---
src/compiler/nir/nir_opt_constant_folding.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/compiler/nir/nir_opt_constant_folding.c b/src/compiler/nir/nir_opt_constant_folding.c
index 05b47d4c0f..5929a60aee 100644
--- a/src/compiler/nir/nir_opt_constant_folding.c
+++ b/src/compiler/nir/nir_opt_constant_folding.c
@@ -131,12 +131,9 @@ constant_fold_intrinsic_instr(nir_intrinsic_instr *instr)
{
bool progress = false;
- if (instr->intrinsic == nir_intrinsic_discard_if) {
- nir_const_value *src_val = nir_src_as_const_value(instr->src[0]);
- if (src_val && src_val->u32[0] == NIR_FALSE) {
- nir_instr_remove(&instr->instr);
- progress = true;
- } else if (src_val && src_val->u32[0] == NIR_TRUE) {
+ if (instr->intrinsic == nir_intrinsic_discard_if &&
+ nir_src_is_const(instr->src[0])) {
+ if (nir_src_as_bool(instr->src[0])) {
/* This method of getting a nir_shader * from a nir_instr is
* admittedly gross, but given the rarity of hitting this case I think
* it's preferable to plumbing an otherwise unused nir_shader *
@@ -151,6 +148,10 @@ constant_fold_intrinsic_instr(nir_intrinsic_instr *instr)
nir_instr_insert_before(&instr->instr, &discard->instr);
nir_instr_remove(&instr->instr);
progress = true;
+ } else {
+ /* We're not discarding, just delete the instruction */
+ nir_instr_remove(&instr->instr);
+ progress = true;
}
}
More information about the mesa-commit
mailing list