https://github.com/halide/Halide
Raw File
Tip revision: 1a4d2c26f4ba8109c5a4ee4cf59519907c7b8b07 authored by Steven Johnson on 05 October 2018, 16:24:32 UTC
Merge branch 'master' into srj-irmut2
Tip revision: 1a4d2c2
Simplify_Not.cpp
#include "Simplify_Internal.h"

namespace Halide {
namespace Internal {

Expr Simplify::visit(const Not *op, ConstBounds *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