return false;
}
-static bool __stmt_type_eq(const struct stmt *stmt_a, const struct stmt *stmt_b)
+static bool __stmt_type_eq(const struct stmt *stmt_a, const struct stmt *stmt_b,
+ bool fully_compare)
{
struct expr *expr_a, *expr_b;
expr_a = stmt_a->expr;
expr_b = stmt_b->expr;
- if (!stmt_expr_supported(expr_a) ||
- !stmt_expr_supported(expr_b))
- return false;
+ if (fully_compare) {
+ if (!stmt_expr_supported(expr_a) ||
+ !stmt_expr_supported(expr_b))
+ return false;
+ }
return __expr_cmp(expr_a->left, expr_b->left);
case STMT_COUNTER:
return false;
}
-static bool stmt_type_eq(const struct stmt *stmt_a, const struct stmt *stmt_b)
-{
- if (!stmt_a && !stmt_b)
- return true;
- else if (!stmt_a)
- return false;
- else if (!stmt_b)
- return false;
-
- return __stmt_type_eq(stmt_a, stmt_b);
-}
-
static bool stmt_type_find(struct optimize_ctx *ctx, const struct stmt *stmt)
{
uint32_t i;
for (i = 0; i < ctx->num_stmts; i++) {
- if (__stmt_type_eq(stmt, ctx->stmt[i]))
+ if (__stmt_type_eq(stmt, ctx->stmt[i], false))
return true;
}
uint32_t i;
for (i = 0; i < ctx->num_stmts; i++) {
- if (__stmt_type_eq(stmt, ctx->stmt[i]))
+ if (__stmt_type_eq(stmt, ctx->stmt[i], false))
return i;
}
/* should not ever happen. */
fprintf(octx->error_fp, "\n");
}
+static bool stmt_type_eq(const struct stmt *stmt_a, const struct stmt *stmt_b)
+{
+ if (!stmt_a && !stmt_b)
+ return true;
+ else if (!stmt_a)
+ return false;
+ else if (!stmt_b)
+ return false;
+
+ return __stmt_type_eq(stmt_a, stmt_b, true);
+}
+
static bool rules_eq(const struct optimize_ctx *ctx, int i, int j)
{
uint32_t k;