[Mesa-dev] [PATCH 03/15] glsl: Modify function inlining to only operate on built-in functions
Ian Romanick
idr at freedesktop.org
Thu Sep 15 22:12:36 UTC 2016
From: Ian Romanick <ian.d.romanick at intel.com>
This will be used in the stand-alone compiler.
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
src/compiler/glsl/glsl_parser_extras.cpp | 2 +-
src/compiler/glsl/ir_optimization.h | 2 +-
src/compiler/glsl/opt_function_inlining.cpp | 12 +++++++-----
src/compiler/glsl/test_optpass.cpp | 2 +-
4 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
index c1e958a..29eba13 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -2042,7 +2042,7 @@ do_common_optimization(exec_list *ir, bool linked,
OPT(lower_instructions, ir, SUB_TO_ADD_NEG);
if (linked) {
- OPT(do_function_inlining, ir);
+ OPT(do_function_inlining, ir, false);
OPT(do_dead_functions, ir);
OPT(do_structure_splitting, ir);
}
diff --git a/src/compiler/glsl/ir_optimization.h b/src/compiler/glsl/ir_optimization.h
index 3bd6928..26f13f1 100644
--- a/src/compiler/glsl/ir_optimization.h
+++ b/src/compiler/glsl/ir_optimization.h
@@ -102,7 +102,7 @@ bool do_dead_code_local(exec_list *instructions);
bool do_dead_code_unlinked(exec_list *instructions);
bool do_dead_functions(exec_list *instructions);
bool opt_flip_matrices(exec_list *instructions);
-bool do_function_inlining(exec_list *instructions);
+bool do_function_inlining(exec_list *instructions, bool only_builtins);
bool do_lower_jumps(exec_list *instructions, bool pull_out_jumps = true, bool lower_sub_return = true, bool lower_main_return = false, bool lower_continue = false, bool lower_break = false);
bool do_lower_texture_projection(exec_list *instructions);
bool do_if_simplification(exec_list *instructions);
diff --git a/src/compiler/glsl/opt_function_inlining.cpp b/src/compiler/glsl/opt_function_inlining.cpp
index 83534bf..f216696 100644
--- a/src/compiler/glsl/opt_function_inlining.cpp
+++ b/src/compiler/glsl/opt_function_inlining.cpp
@@ -43,9 +43,10 @@ namespace {
class ir_function_inlining_visitor : public ir_hierarchical_visitor {
public:
- ir_function_inlining_visitor()
+ ir_function_inlining_visitor(bool only_builtins)
+ : progress(false), only_builtins(only_builtins)
{
- progress = false;
+ /* empty */
}
virtual ~ir_function_inlining_visitor()
@@ -60,14 +61,15 @@ public:
virtual ir_visitor_status visit_enter(ir_swizzle *);
bool progress;
+ bool only_builtins;
};
} /* unnamed namespace */
bool
-do_function_inlining(exec_list *instructions)
+do_function_inlining(exec_list *instructions, bool only_builtins)
{
- ir_function_inlining_visitor v;
+ ir_function_inlining_visitor v(only_builtins);
v.run(instructions);
@@ -246,7 +248,7 @@ ir_function_inlining_visitor::visit_enter(ir_swizzle *ir)
ir_visitor_status
ir_function_inlining_visitor::visit_enter(ir_call *ir)
{
- if (can_inline(ir)) {
+ if ((!only_builtins || ir->callee->is_builtin()) && can_inline(ir)) {
ir->generate_inline(ir);
ir->remove();
this->progress = true;
diff --git a/src/compiler/glsl/test_optpass.cpp b/src/compiler/glsl/test_optpass.cpp
index 852af19..3771a89 100644
--- a/src/compiler/glsl/test_optpass.cpp
+++ b/src/compiler/glsl/test_optpass.cpp
@@ -87,7 +87,7 @@ do_optimization(struct exec_list *ir, const char *optimization,
} else if (strcmp(optimization, "do_dead_functions") == 0) {
return do_dead_functions(ir);
} else if (strcmp(optimization, "do_function_inlining") == 0) {
- return do_function_inlining(ir);
+ return do_function_inlining(ir, false);
} else if (sscanf(optimization,
"do_lower_jumps ( %d , %d , %d , %d , %d ) ",
&int_0, &int_1, &int_2, &int_3, &int_4) == 5) {
--
2.5.5
More information about the mesa-dev
mailing list