An upper limit guard is set for a valve overlap amount according to a KCS
learning value used to retard-correct an ignition timing in order to
suppress knock, and an engine load. As a result, it is possible to make
the upper limit guard value a value able to restrict the valve overlap
amount to a value equal to, or less than, a value at which an internal EGR
amount does not become excessive during a retard-correction of the
ignition timing. By applying the upper limit guard to the valve overlap
amount using the upper limit guard value, it is possible to suppress the
valve overlap amount from increasing from the optimum value following a
retard-correction of the ignition timing, as well as suppress the value of
overlap amount from being reduced when it is not deviating from the
optimum value and is below the upper limit guard value.