From d53a1b6b572370e303e42e9238abc458d4c22b64 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Mon, 4 Feb 2019 22:29:31 -0500 Subject: opt: Optimize -samefile together with -inum --- opt.c | 9 +++++++++ 1 file changed, 9 insertions(+) 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) { -- cgit v1.2.3