A spectrum splitter can be used to spatially multiplex different solar cells that have high efficiency in mutually exclusive parts of the solar spectrum. We investigated the use of a grating, comprising an array of dielectric cylinders embedded in a dielectric slab, for specularly transmitting one part of the solar spectrum while the other part is transmitted nonspecularly and the total reflectance is very low. A combination of (1) the rigorous coupled-wave approach for computing the reflection and transmission coefficients of the grating and (2) the differential evolution algorithm for optimizing the grating geometry and the refractive indices of dielectric materials was devised as a design tool. We used this tool to optimize two candidate gratings and obtained definite improvements to the initial guesses for the structural and constitutive parameters. Significant spectrum splitting can be achieved if the angle of incidence does not exceed 15 deg.