Encountered a strange behaviour with undef. Below is a minimal reproduction of the problem:
#include <Halide.h>
using namespace Halide;
int main() {
Var x{"x"};
Func f{"f"}, g{"g"};
f(x) = select(x == 0, x + 1, undef<int>());
g(x) = select(x == 0, f(x), -f(1 - x));
g.trace_stores();
Buffer<int> output = g.realize({4});
return 0;
}
Output is
Begin pipeline g.0()
Tag g.0() tag = "func_type_and_dim: 1 0 32 1 1 0 4"
Store g.0(1) = -1
End pipeline g.0()
g.0(0) did not get computed.