If you can afford to do the change globally, you could define a global add
function (as a function pointer):
var simd_add*: proc (x: int, y: int): int {.nimcall.}
then at startup, you'd seed the function pointer with the appropriate code:
if avx_detected():
simd_add = avx_add
elif sse_detected():
simd_add = sse_add
else:
simd_add = default_add
and everywhere else in your code, you could have:
let c = simd_add(1, 2)
(you could use macros to rewrite regular additions `+` to `simd_add` for
convenience)