ast_propagate_effects(self, left);
ast_propagate_effects(self, right);
- /*
- * Try to fold away superfluous binary operations, such as:
- * A * 1, a + 0, etc.
- */
- if ((fold = (ast_binary*)fold_superfluous(left, right, op))) {
+ if (OPTS_OPTIMIZATION(OPTIM_PEEPHOLE) && (fold = (ast_binary*)fold_superfluous(left, right, op))) {
ast_binary_delete(self);
return fold;
}
}
else if (op == INSTR_BITAND || op == INSTR_BITOR)
self->expression.vtype = TYPE_FLOAT;
- else if (op == INSTR_MUL_FV || op == INSTR_MUL_FV)
+ else if (op == INSTR_MUL_VF || op == INSTR_MUL_FV)
self->expression.vtype = TYPE_VECTOR;
+ else if (op == INSTR_MUL_V)
+ self->expression.vtype = TYPE_FLOAT;
else
self->expression.vtype = left->vtype;
ast_unary *prev = (ast_unary*)((ast_unary*)expr)->operand;
/* Handle for double negation */
- if ((((ast_unary*)expr)->op == VINSTR_NEG_V && op == VINSTR_NEG_V) ||
- (((ast_unary*)expr)->op == VINSTR_NEG_F && op == VINSTR_NEG_F)) {
+ if (((ast_unary*)expr)->op == op)
prev = (ast_unary*)((ast_unary*)expr)->operand;
- }
if (ast_istype(prev, ast_unary)) {
ast_expression_delete((ast_expression*)self);
if (!vtype) {
compile_error(ast_ctx(self), "internal error: ast_function_new condition 0");
goto cleanup;
+ } else if (vtype->hasvalue || vtype->expression.vtype != TYPE_FUNCTION) {
} else if (vtype->hasvalue || vtype->expression.vtype != TYPE_FUNCTION) {
compile_error(ast_ctx(self), "internal error: ast_function_new condition %i %i type=%i (probably 2 bodies?)",
(int)!vtype,
ir_value *dummy;
ast_expression *ec;
ast_expression_codegen *cgen;
+
size_t i;
(void)ir;