The following code should be great, because g's values should rotate through 8 registers instead of ever touching memory. However sliding window can't slide over multiple nested loops at once (x, xi in this case), which is necessary to make this work.
g(x) = x;
f(x) = g(x-2) + g(x+2);
g.fold_storage(x, 8).store_root().compute_at(f, xi);
f.split(x, x, xi, 8, TailStrategy::RoundUp).unroll(xi);