I don't think it is safe. Because i++ would really mean something like
In INTEL:
movl i, AX
inc AX
In AMD:
movl $0, -4(%rbp)
addl $1, -4(%rbp)
So, in effect, it is two assembly instructions, and if the context switch happens in between, then the data is corrupted