By a classical result of Birkhoff (that is, Theorem 2 in [G. Birkhoff, Subdirect unions in universal algebra, Bull. AMS, 1944]) and the trivial fact that the class of semigroups is closed under the taking of homomorphic images within the category of magmas, every semigroup is (isomorphic to) a subdirect product of subdirectly irreducible semigroups.
What about cancellative semigroups? More precisely:
Q. Is every cancellative semigroup a subdirect product of subdirectly irreducible, cancellative semigroups?
If a semigroup $T$ is the homomorphic image of a cancellative semigroup $S$, then $T$ need not be cancellative (otherwise we would be done). However, I am hoping that there is a generalization of Birkhoff's theorem that applies not only to (finitary) algebras in the sense of Birkhoff's paper, but also to algebras (such as cancellative semigroups) that satisfy certain equational implications.
UPDATE 1. Below, Keith Kearnes proves that every cancellative commutative semigroup is a subdirect product of (subdirectly irreducible) groups. This provides a strong affirmative answer to my question in the commutative setting, and it is perhaps worth remarking that nothing similar can generally be true in the non-commutative setting: otherwise, every cancellative semigroup would embed into a group, which is not the case, as first proved by Mal'cev in [Math. Ann. 113 (1937), No. 1, 686-691]. It thus seems natural to ask what happens in the specific situation when $S$ embeds into a group, and I did it in a separate thread (here).