summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2019-02-04 22:29:31 -0500
committerTavian Barnes <tavianator@tavianator.com>2019-02-04 22:29:31 -0500
commitd53a1b6b572370e303e42e9238abc458d4c22b64 (patch)
tree009fd26e04a807810914bbcc1eeb0ca62d008d70
parent3a52c0e1f55d5dd03a00740c191569b9309c0ad6 (diff)
downloadbfs-d53a1b6b572370e303e42e9238abc458d4c22b64.tar.xz
opt: Optimize -samefile together with -inum
-rw-r--r--opt.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/opt.c b/opt.c
index b3abf37..1157754 100644
--- a/opt.c
+++ b/opt.c
@@ -619,6 +619,13 @@ static void infer_icmp_facts(struct opt_state *state, const struct expr *expr, e
}
}
+/** Infer data flow facts about a -samefile expression. */
+static void infer_samefile_facts(struct opt_state *state, const struct expr *expr) {
+ struct range *range_when_true = state->facts_when_true.ranges + INUM_RANGE;
+ constrain_min(range_when_true, expr->ino);
+ constrain_max(range_when_true, expr->ino);
+}
+
/** Infer data flow facts about a -type expression. */
static void infer_type_facts(struct opt_state *state, const struct expr *expr) {
state->facts_when_true.types &= expr->idata;
@@ -643,6 +650,8 @@ static struct expr *optimize_expr_recursive(struct opt_state *state, struct expr
infer_icmp_facts(state, expr, INUM_RANGE);
} else if (expr->eval == eval_links) {
infer_icmp_facts(state, expr, LINKS_RANGE);
+ } else if (expr->eval == eval_samefile) {
+ infer_samefile_facts(state, expr);
} else if (expr->eval == eval_size) {
infer_icmp_facts(state, expr, SIZE_RANGE);
} else if (expr->eval == eval_type) {