  In this work, we investigate the two-step backward differentiation formula
(BDF2) with nonuniform grids for the Allen-Cahn equation. We show that the
nonuniform BDF2 scheme is energy stable under the time-step ratio restriction
$r_k:=\tau_k/\tau_{k-1}<(3+\sqrt{17})/2\approx3.561.$ Moreover, by developing a
novel kernel recombination and complementary technique, we show, for the first
time, the discrete maximum principle of BDF2 scheme under the time-step ratio
restriction $r_k<1+\sqrt{2}\approx 2.414$ and a practical time step constraint.
The second-order rate of convergence in the maximum norm is also presented.
Numerical experiments are provided to support the theoretical findings.
