mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-24 20:51:35 +00:00
[qfcc] Convert chained scales to scale by product
That is, scale(scale(A,b),c) becomes scale(A,b*c), thus giving the expression dag more opportunities to find common sub-expressions. My fancy zero test is down to 20 total instructions (including overhead, or 16 for the actual algebra).
This commit is contained in:
parent
bc63f211bb
commit
4bf6ce45d4
1 changed files with 6 additions and 0 deletions
|
@ -656,6 +656,12 @@ scale_expr (type_t *type, const expr_t *a, const expr_t *b)
|
||||||
b = neg_expr (b);
|
b = neg_expr (b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (a->type == ex_expr && a->expr.op == SCALE) {
|
||||||
|
// covert scale (scale (X, y), z) to scale (X, y*z)
|
||||||
|
b = scale_expr (get_type (b), b, a->expr.e2);
|
||||||
|
a = a->expr.e1;
|
||||||
|
}
|
||||||
|
|
||||||
auto scale = typed_binary_expr (type, op, a, b);
|
auto scale = typed_binary_expr (type, op, a, b);
|
||||||
scale = fold_constants (scale);
|
scale = fold_constants (scale);
|
||||||
scale = edag_add_expr (scale);
|
scale = edag_add_expr (scale);
|
||||||
|
|
Loading…
Reference in a new issue