exec.c: add a check between constants to see whether we could skip

The maximum level is defined as P_L2_LEVELS and skip is defined with 6
bits, which means if P_L2_LEVELS < (1 << 6), skip never exceeds the
boundary.

Since this check is between two constants, which leverages compiler
to optimize the code based on different configuration.

Backports commit 526ca2360ea1cd947f74c8c6c38b91b9d6fcfdb5 from qemu
This commit is contained in:
Wei Yang 2019-11-20 13:15:56 -05:00 committed by Lioncash
parent 623632f3ac
commit 813ec29d3c
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -247,7 +247,8 @@ static void phys_page_compact(PhysPageEntry *lp, Node *nodes, unsigned long *com
assert(valid_ptr < P_L2_SIZE);
/* Don't compress if it won't fit in the # of bits we have. */
if (lp->skip + p[valid_ptr].skip >= (1 << 6)) {
if (P_L2_LEVELS >= (1 << 6) &&
lp->skip + p[valid_ptr].skip >= (1 << 6)) {
return;
}