[Mesa-dev] [PATCH 02/22] glsl: Lower ifs to conditional-select instead of conditional-assign
Ian Romanick
idr at freedesktop.org
Thu Sep 21 14:34:15 UTC 2017
From: "\"Ian Romanick\"" <idr at freedesktop.org>
From: Ian Romanick <ian.d.romanick at intel.com>
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
src/compiler/glsl/lower_if_to_cond_assign.cpp | 22 ++++++++-----------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/src/compiler/glsl/lower_if_to_cond_assign.cpp b/src/compiler/glsl/lower_if_to_cond_assign.cpp
index 0d6aa00..42163c3 100644
--- a/src/compiler/glsl/lower_if_to_cond_assign.cpp
+++ b/src/compiler/glsl/lower_if_to_cond_assign.cpp
@@ -189,22 +189,18 @@ move_block_to_cond_assign(void *mem_ctx,
_mesa_set_search(
set, assign->lhs->variable_referenced()) != NULL;
- if (!assign->condition) {
- if (assign_to_cv) {
- assign->rhs =
- new(mem_ctx) ir_expression(ir_binop_logic_and,
- glsl_type::bool_type,
- cond_expr->clone(mem_ctx, NULL),
- assign->rhs);
- } else {
- assign->condition = cond_expr->clone(mem_ctx, NULL);
- }
- } else {
- assign->condition =
+ if (assign_to_cv) {
+ assign->rhs =
new(mem_ctx) ir_expression(ir_binop_logic_and,
glsl_type::bool_type,
cond_expr->clone(mem_ctx, NULL),
- assign->condition);
+ assign->rhs);
+ } else {
+ assign->rhs =
+ new(mem_ctx) ir_expression(ir_triop_csel,
+ cond_expr->clone(mem_ctx, NULL),
+ assign->rhs,
+ assign->lhs->clone(mem_ctx, NULL));
}
}
}
--
2.9.5
More information about the mesa-dev
mailing list