mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-25 13:11:00 +00:00
[qfcc] Optimize matrix construction from vectors
When the number of supplied vectors matches the number of columns in the matrix and all vectors have the same width as the number of rows in the matrix, there's no need to expand the vectors into components only to be gathered again.
This commit is contained in:
parent
14e39627cc
commit
81aa77b142
1 changed files with 18 additions and 0 deletions
|
@ -229,6 +229,24 @@ math_constructor (const type_t *type, const expr_t *params, const expr_t *e)
|
||||||
return construct_matrix (type, param_exprs[0], e);
|
return construct_matrix (type, param_exprs[0], e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (is_matrix (type) && num_param == type_cols (type)) {
|
||||||
|
bool by_vector = true;
|
||||||
|
for (int i = 0; i < type_cols (type); i++) {
|
||||||
|
auto ptype = get_type (param_exprs[i]);
|
||||||
|
if (!is_nonscalar (ptype)
|
||||||
|
|| type_width (ptype) != type_rows (type)) {
|
||||||
|
by_vector = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (by_vector) {
|
||||||
|
auto mat = new_expr ();
|
||||||
|
mat->type = ex_vector;
|
||||||
|
mat->vector.type = type;
|
||||||
|
list_gather (&mat->vector.list, param_exprs, type_cols (type));
|
||||||
|
return mat;
|
||||||
|
}
|
||||||
|
}
|
||||||
return construct_by_components (type, params, e);
|
return construct_by_components (type, params, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue