Kinetic energy flux (KEF) is an important physical quantity that characterizes cascades of kinetic energy in turbulent flows. In large-eddy simulation (LES), it is crucial for the subgrid-scale (SGS) model to accurately predict the KEF in turbulence. In this paper, we propose a new eddy-viscosity SGS model constrained by the properly modelled KEF for LES of compressible wall-bounded turbulence. The new methodology has the advantages of both accurate prediction of the KEF and strong numerical stability in LES. We can obtain an approximate KEF by the tensor-diffusivity model, which has a high correlation with the real value. Then, using the artificial neural network method, the local ratios between the real KEF and the approximate KEF are accurately modelled. Consequently, the SGS model can be improved by the product of that ratio and the approximate KEF. In LES of compressible turbulent channel flow, the new model can accurately predict mean velocity profile, turbulence intensities, Reynolds stress, temperature–velocity correlation, etc. Additionally, for the case of a compressible flat-plate boundary layer, the new model can accurately predict some key quantities, including the onset of transitions and transition peaks, the skin-friction coefficient, the mean velocity in the turbulence region, etc., and it can also predict the energy backscatters in turbulence. Furthermore, the proposed model also shows more advantages for coarser grids.