If $V$ is a finite dimensional $k$-vector space and $T : V \rightarrow V$ is a $k$-linear map, and suppose that $T$ satisfies a polynomial $f$ with coefficients in $k$. Suppose also that $f(x)$ factors as a product of irreducible polynomials $\{ m_{i} \}_{i=1}^{n}$ over $k$, so that $f(x) = \prod_{i=1}^{n}m_i(x)$ over $k$.
Then if we let $W_{i} = \operatorname{ker}(m_{i}(T)$), then by the primary decomposition theorem, each $W_{i}$ is a $T$-invariant subspace of $V$ and furthermore $V$ decomposes as a direct sum of the $W_{i}$.
My question then is are these $W_{i}$ (and partial direct sums of these $W_{i}$) exactly the $T$-invariant subspaces of $V$? That is to say that if $U$ is a $T$-invariant subspace of $V$, then does $U$ necessarily decompose as a partial-direct sum of the $W_{i}$?
Edit: If $k$ is any field the identity operator on $k^2$ is a counterexample. Making the original version of this answer a little dumb:
Original: Not necessarily. Consider the operator $T$ on $\Bbb R^4$ defined by the matrix $$\begin{bmatrix}0&1&0&0 \\-1&0&0&0 \\0&0&0&1 \\0&0&-1&0\end{bmatrix}.$$
Then $f(T)=0$ if $f(x)=x^2+1$, which is irreducible (over $\Bbb R$). So there is only one $W_i$, namely $W_1=\Bbb R^4$. But $U=\{x:x_3=x_4=0\}$ is invariant.