1 #include "PurifyIndexMath.h" 2 #include "IRMutator.h" 3 #include "IROperator.h" 4 #include "Simplify.h" 5 6 namespace Halide { 7 namespace Internal { 8 9 class PurifyIndexMath : public IRMutator { 10 using IRMutator::visit; 11 visit(const Call * op)12 Expr visit(const Call *op) override { 13 if (op->is_intrinsic(Call::signed_integer_overflow)) { 14 // This should only occur for values that are evaluated 15 // but never actually used (e.g. on select branches that 16 // are unreachable). Just replace it with zero. 17 return make_zero(op->type); 18 } else { 19 return IRMutator::visit(op); 20 } 21 } 22 }; 23 purify_index_math(const Expr & s)24Expr purify_index_math(const Expr &s) { 25 return PurifyIndexMath().mutate(s); 26 } 27 28 } // namespace Internal 29 } // namespace Halide 30