Maratyszcza / NNPACK

Acceleration package for neural networks on multi-core CPUs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

potential unitialized variable in nnp_sgemm_upto_4x8__psimd

yonghong-song opened this issue · comments

In src/psimd/blas/sgemm.c, we have

void nnp_sgemm_upto_4x8__psimd(uint32_t mr, uint32_t nr, size_t k, size_t update, const float* a, const float* b, float* c, size_t row_stride_c) {
	psimd_f32 vc00, vc01, vc10, vc11, vc20, vc21, vc30, vc31;
	vc00 = vc01 = vc10 = vc11 = vc20 = vc21 = vc30 = vc31 = psimd_zero_f32();
	do {
		psimd_f32 vb0, vb1;
		
		vb0 = psimd_load_f32(b);
		b += 4;
		if (nr > 4) {
			vb1 = psimd_load_f32(b);
			b += 4;
		}
...

Here, vb1 could be potentially uninitialized if nr <= 4.
Is this something we should worry about? In one of our
compilations, compiler complains

variable 'vb1' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
                if (nr > 4) {
                    ^~~~~~

The variable is indeed uninitialized when nr <= 4, but it doesn't affect the correctness because its final value is discarded in this case.