not knowing the internals I don't know if it is possible to safely write matrix multiplication in the form like
gemm(A, A, A)
where (e.g.) all matrices are the same, or one has to use some temporary matrix as
(The code above should return A = A + A*A.)
All documentation usually mentions that in gemm(A,B,C) A, B are untouched and C is overwritten. But this really does not answer the question since it somehow expects A, B, C to be different (or at least that C is different from A and B).