[6/6] exec.c: add a check between constants to see whether we could skip
diff mbox series

Message ID 20190321082555.21118-7-richardw.yang@linux.intel.com
State New
Headers show
Series
  • Refine exec
Related show

Commit Message

Wei Yang March 21, 2019, 8:25 a.m. UTC
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.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
 exec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/exec.c b/exec.c
index 6c660f656c..5d71fdb89f 100644
--- a/exec.c
+++ b/exec.c
@@ -322,7 +322,8 @@  static void phys_page_compact(PhysPageEntry *lp, Node *nodes)
     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;
     }