diff options
author | marha <marha@users.sourceforge.net> | 2015-04-30 23:26:47 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2015-04-30 23:29:47 +0200 |
commit | 055e5645a789d2822d3c4e5a3bc81ff6a969ff31 (patch) | |
tree | 8a923f19c3586f9341114be6c81784ab9018aef8 /mesalib/src/glsl/opt_algebraic.cpp | |
parent | 0f7871ff824bcf064db3ab6bdfe26645ba6c8087 (diff) | |
parent | a71d524ecad48837e0124a03124bc05f59a48be7 (diff) | |
download | vcxsrv-055e5645a789d2822d3c4e5a3bc81ff6a969ff31.tar.gz vcxsrv-055e5645a789d2822d3c4e5a3bc81ff6a969ff31.tar.bz2 vcxsrv-055e5645a789d2822d3c4e5a3bc81ff6a969ff31.zip |
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'mesalib/src/glsl/opt_algebraic.cpp')
-rw-r--r-- | mesalib/src/glsl/opt_algebraic.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/mesalib/src/glsl/opt_algebraic.cpp b/mesalib/src/glsl/opt_algebraic.cpp index 3d2f2ca0b..fa5db70f2 100644 --- a/mesalib/src/glsl/opt_algebraic.cpp +++ b/mesalib/src/glsl/opt_algebraic.cpp @@ -99,6 +99,12 @@ is_vec_two(ir_constant *ir) } static inline bool +is_vec_four(ir_constant *ir) +{ + return (ir == NULL) ? false : ir->is_value(4.0, 4); +} + +static inline bool is_vec_negative_one(ir_constant *ir) { return (ir == NULL) ? false : ir->is_negative_one(); @@ -774,6 +780,20 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) return mul(x, x); } + if (is_vec_four(op_const[1])) { + ir_variable *x = new(ir) ir_variable(ir->operands[1]->type, "x", + ir_var_temporary); + base_ir->insert_before(x); + base_ir->insert_before(assign(x, ir->operands[0])); + + ir_variable *squared = new(ir) ir_variable(ir->operands[1]->type, + "squared", + ir_var_temporary); + base_ir->insert_before(squared); + base_ir->insert_before(assign(squared, mul(x, x))); + return mul(squared, squared); + } + break; case ir_binop_min: |