Since S is a free R module, multiplication is defined by the image of the basis elements 1, x, x2, x3, etc. Multiplication by x, for instance, maps this basis to x, x2, x3, and so on up to xn-w(x). Write a matrix M that defines multiplication for all of S. Now S has a zero divisor iff an input vector times M yields the zero vector. Therefore S has no zero divisors, and w is irreducible, iff M is nonsingular. This can often be computed directly, using gaussian elimination. Embed R in its fraction field if necessary.
If R is already a field, such as the integers mod p, then we're good to go. The polynomial w defines a finite field extension of dimension n iff the corresponding matrix has a nonzero determinant.
Let w be a monic polynomial of degree n, with components w1 and w2. Since 1 projects to 1, both w1 and w2 are monic of degree n. These components are irreducible iff the corresponding matrices are nonsingular, iff both determinants are nonzero. This happens iff the matrix of w, over R, has a determinant that does not belong to I or J.
In some cases this is easily calculated. For instance, let R be Z, and let I be the multiples of 3, and let J be the multiples of 5. All calculations will now be taken in Q3, or the integers mod 15. Given a monic polynomial w, which may have thousands of terms, build the matrix M and take its determinant. Then check for divisibility by 3 or 5. Both w1 and w2 are irreducible iff det(M) is a unit mod 15.
Put this all together and let w be a monic polynomial whose coefficients are integers mod d. now w is irreducible mod each prime power if the determinant of the corresponding matrix is a unit mod d.