@wsmoses I went back to a simple example adding three entries of a vector and tried, unsuccessfully, to generate the derivative with -enzyme-auto-sparsity=1. This is the simplest example I can think of.
The function to differentiate is:
f[0] = y[0] + y[1] + y[2];
Here is the Enzyme explorer reproducer: https://fwd.gymni.ch/bqPzQv
The cannot tell if depends on loop iv: (zext i1 %20 to i64) error does come from the if (val == 0.0) boolean in sparse_store, but that is precisely what should help with the sparsity detection, and it works in most other cases. Adding two entries instead, or flipping one of the signs in the ternary operation works. The underlying issue has to be elsewhere.
For reference, I came across the issue in a larger function evaluation: https://fwd.gymni.ch/X7pLQp.
cc @pelesh