aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl/nir/nir_opt_copy_propagate.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2015-03-05 23:40:39 +0100
committermarha <marha@users.sourceforge.net>2015-03-05 23:42:09 +0100
commitc646056120fe14e4c4ccf81bac5d78d61225a8e8 (patch)
treeba0af42750f0ab6dc4724342a7063835636222b5 /mesalib/src/glsl/nir/nir_opt_copy_propagate.c
parent87e58a93f7248171e736656080069cb65ff56aae (diff)
parent8574eba804031f6b19713f0b02952280730bf62e (diff)
downloadvcxsrv-c646056120fe14e4c4ccf81bac5d78d61225a8e8.tar.gz
vcxsrv-c646056120fe14e4c4ccf81bac5d78d61225a8e8.tar.bz2
vcxsrv-c646056120fe14e4c4ccf81bac5d78d61225a8e8.zip
Merge remote-tracking branch 'origin/released'
Conflicts: mesalib/src/mesa/drivers/dri/swrast/swrast.c mesalib/src/mesa/main/.gitignore mesalib/src/mesa/main/queryobj.c
Diffstat (limited to 'mesalib/src/glsl/nir/nir_opt_copy_propagate.c')
-rw-r--r--mesalib/src/glsl/nir/nir_opt_copy_propagate.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/mesalib/src/glsl/nir/nir_opt_copy_propagate.c b/mesalib/src/glsl/nir/nir_opt_copy_propagate.c
index dd0ec01ef..ee78e5aa0 100644
--- a/mesalib/src/glsl/nir/nir_opt_copy_propagate.c
+++ b/mesalib/src/glsl/nir/nir_opt_copy_propagate.c
@@ -53,22 +53,6 @@ static bool is_move(nir_alu_instr *instr)
}
-static bool
-is_swizzleless_move(nir_alu_instr *instr)
-{
- if (!is_move(instr))
- return false;
-
- for (unsigned i = 0; i < 4; i++) {
- if (!((instr->dest.write_mask >> i) & 1))
- break;
- if (instr->src[0].swizzle[i] != i)
- return false;
- }
-
- return true;
-}
-
static bool is_vec(nir_alu_instr *instr)
{
for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++)
@@ -80,6 +64,35 @@ static bool is_vec(nir_alu_instr *instr)
instr->op == nir_op_vec4;
}
+static bool
+is_swizzleless_move(nir_alu_instr *instr)
+{
+ if (is_move(instr)) {
+ for (unsigned i = 0; i < 4; i++) {
+ if (!((instr->dest.write_mask >> i) & 1))
+ break;
+ if (instr->src[0].swizzle[i] != i)
+ return false;
+ }
+ return true;
+ } else if (is_vec(instr)) {
+ nir_ssa_def *def = NULL;
+ for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++) {
+ if (instr->src[i].swizzle[0] != i)
+ return false;
+
+ if (def == NULL) {
+ def = instr->src[i].src.ssa;
+ } else if (instr->src[i].src.ssa != def) {
+ return false;
+ }
+ }
+ return true;
+ } else {
+ return false;
+ }
+}
+
typedef struct {
nir_ssa_def *def;
bool found;