https://github.com/halide/Halide
Raw File
Tip revision: e154e175d0b8338329e857ab28d3045f17b26ffe authored by dsharletg on 30 April 2019, 06:59:07 UTC
Merge branch 'master' of https://github.com/halide/Halide into cuda-constant
Tip revision: e154e17
Simplify_Not.cpp
#include "Simplify_Internal.h"

namespace Halide {
namespace Internal {

Expr Simplify::visit(const Not *op, ExprInfo *bounds) {
    Expr a = mutate(op->a, nullptr);

    auto rewrite = IRMatcher::rewriter(IRMatcher::not_op(a), op->type);

    if (rewrite(!c0, fold(!c0)) ||
        rewrite(!(x < y), y <= x) ||
        rewrite(!(x <= y), y < x) ||
        rewrite(!(x > y), y >= x) ||
        rewrite(!(x >= y), y > x) ||
        rewrite(!(x == y), x != y) ||
        rewrite(!(x != y), x == y) ||
        rewrite(!!x, x)) {
        return rewrite.result;
    }

    if (rewrite(!broadcast(x), broadcast(!x, op->type.lanes())) ||
        rewrite(!intrin(Call::likely, x), intrin(Call::likely, !x)) ||
        rewrite(!intrin(Call::likely_if_innermost, x), intrin(Call::likely_if_innermost, !x))) {
        return mutate(std::move(rewrite.result), bounds);
    }

    if (a.same_as(op->a)) {
        return op;
    } else {
        return Not::make(a);
    }
}

}
}
back to top