Revision 799236949867b6a2be0d492137b36a0b67011622 authored by Andrew Adams on 07 December 2021, 16:16:50 UTC, committed by GitHub on 07 December 2021, 16:16:50 UTC
* Add a version of fast_integer_divide that rounds towards zero

* clang-format

* Fix test condition

* Clean up debugging code

* Add explanatory comment to performance test

* Pacify clang tidy
1 parent fb305fd
Raw File
PurifyIndexMath.cpp
#include "PurifyIndexMath.h"
#include "IRMutator.h"
#include "IROperator.h"
#include "Simplify.h"

namespace Halide {
namespace Internal {

namespace {

class PurifyIndexMath : public IRMutator {
    using IRMutator::visit;

    Expr visit(const Call *op) override {
        if (op->is_intrinsic(Call::signed_integer_overflow)) {
            // This should only occur for values that are evaluated
            // but never actually used (e.g. on select branches that
            // are unreachable). Just replace it with zero.
            return make_zero(op->type);
        } else {
            return IRMutator::visit(op);
        }
    }
};

}  // namespace

Expr purify_index_math(const Expr &s) {
    return PurifyIndexMath().mutate(s);
}

}  // namespace Internal
}  // namespace Halide
back to top