[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:
Bill Currie 2023-09-28 15:57:32 +09:00
parent bc63f211bb
commit 4bf6ce45d4

View file

@ -656,6 +656,12 @@ scale_expr (type_t *type, const expr_t *a, const expr_t *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);
scale = fold_constants (scale);
scale = edag_add_expr (scale);