For a HCCI gasoline combustion engine controlled by burnt residual gas, management of the residual gas and thermal distribution in cylinder is a possible way to optimize the auto-ignition and combustion phasing. The management ability of intake valve on the distribution and its effects on auto-ignition are investigated via KIVA code. The thermal and composition inhomogeneous distribution is quantified as inhomogeneity. The results show that, the thermal inhomogeneous distribution correlates well with that of the residual gas. As the residual gas fraction increases, the residual gas fraction inhomogeneity and the temperature inhomogeneity tend to increase. The residual gas fraction, as well as the in-cylinder residual gas inhomogeneity and temperature inhomogeneity, increases greatly with earlier exhaust valve close timing. When the residual gas fraction is larger than 40%, late intake valve open timing leads to high in-cylinder inhomogeneity. However, it is not as effective when it is applied to low residual gas fractions, whereas the intake valve lift is helpful in controlling the in-cylinder inhomogeneity at both high and low residual gas fractions. The in-cylinder inhomogeneity increases as the intake valve lift increases, while residual gas fraction changes little with valve lift even in low residual gas fraction condition. Higher temperature inhomogeneity results in earlier auto-ignition timing at the same average condition inside the cylinder. The occurrence and development of auto-ignition are strongly affected by the residual gas and thermal distributions. A higher residual gas fraction level advances the auto-ignition occurrence; however the auto-ignition develops the fastest at the medium residual gas fraction level, which means that such a residual gas fraction enables the shortest period from occurrence of the first auto-ignition site to CA10; At low residual gas fractions, the development of auto-ignition is slow at the beginning, but then accelerates abruptly and promotes bulks of the mixture to ignite simultaneously. At the same residual gas fraction level, the thermal and residual gas fraction inhomogeneities can be changed by variable intake valve timing and lift, and the inhomogeneities can affect the timing and development of auto-ignition. Higher thermal inhomogeneity results in advanced auto-ignition timing. The auto-ignition timing is more sensitive at high residual gas fractions than that at low residual gas fractions.