Check if kernels stashed on form match optimisations

We stash the compiled kernels on the form so we don't have to recompile
if we assemble the same form again with the same optimisations. If the
optimisations have changed we do want to regenerate the kernels.