Index: /trunk/src/VBox/VMM/VMMAll/IEMAllInstPython.py
===================================================================
--- /trunk/src/VBox/VMM/VMMAll/IEMAllInstPython.py	(revision 101567)
+++ /trunk/src/VBox/VMM/VMMAll/IEMAllInstPython.py	(revision 101568)
@@ -2886,5 +2886,5 @@
     'IEM_MC_IF_ECX_IS_NZ_AND_EFL_BIT_NOT_SET':                   (McBlock.parseMcGenericCond,       True,  False, ),
     'IEM_MC_IF_ECX_IS_NZ_AND_EFL_BIT_SET':                       (McBlock.parseMcGenericCond,       True,  False, ),
-    'IEM_MC_IF_EFL_ANY_BITS_SET':                                (McBlock.parseMcGenericCond,       True,  False, ),
+    'IEM_MC_IF_EFL_ANY_BITS_SET':                                (McBlock.parseMcGenericCond,       True,  True,  ),
     'IEM_MC_IF_EFL_BIT_NOT_SET':                                 (McBlock.parseMcGenericCond,       True,  False, ),
     'IEM_MC_IF_EFL_BIT_NOT_SET_AND_BITS_EQ':                     (McBlock.parseMcGenericCond,       True,  False, ),
Index: /trunk/src/VBox/VMM/VMMAll/IEMAllN8veRecompiler.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMAll/IEMAllN8veRecompiler.cpp	(revision 101567)
+++ /trunk/src/VBox/VMM/VMMAll/IEMAllN8veRecompiler.cpp	(revision 101568)
@@ -4253,4 +4253,33 @@
 
 
+#define IEM_MC_IF_EFL_ANY_BITS_SET(a_fBits) \
+        off = iemNativeEmitIfEflagAnysBitsSet(pReNative, off, (a_fBits)); \
+        AssertReturn(off != UINT32_MAX, UINT32_MAX); \
+        do {
+
+/** Emits code for IEM_MC_IF_EFL_ANY_BITS_SET. */
+DECLINLINE(uint32_t) iemNativeEmitIfEflagAnysBitsSet(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint32_t fBitsInEfl)
+{
+    PIEMNATIVECOND pEntry = iemNativeCondPushIf(pReNative);
+    AssertReturn(pEntry, UINT32_MAX);
+
+    /* Get the eflags. */
+    uint8_t const idxEflReg = iemNativeRegAllocTmpForGuestReg(pReNative, &off, kIemNativeGstReg_EFlags,
+                                                              kIemNativeGstRegUse_ReadOnly);
+    AssertReturn(idxEflReg != UINT8_MAX, UINT32_MAX);
+
+    /* Test and jump. */
+    off = iemNativeEmitTestAnyBitsInGprAndJmpToLabelIfNoneSet(pReNative, off, idxEflReg, fBitsInEfl, pEntry->idxLabelElse);
+
+    /* Free but don't flush the EFlags register. */
+    iemNativeRegFreeTmp(pReNative, idxEflReg);
+
+    /* Make a copy of the core state now as we start the if-block. */
+    iemNativeCondStartIfBlock(pReNative, off);
+
+    return off;
+}
+
+
 #define IEM_MC_IF_EFL_BIT_SET(a_fBit) \
         off = iemNativeEmitIfEflagsBitSet(pReNative, off, (a_fBit)); \
@@ -4594,7 +4623,7 @@
                         case kIemTbDbgEntryType_Label:
                         {
-                            const char *pszName     = "what_the_fudge";
-                            const char *pszCommment = "";
-                            bool        fNumbered   = pDbgInfo->aEntries[iDbgEntry].Label.uData != 0;
+                            const char *pszName    = "what_the_fudge";
+                            const char *pszComment = "";
+                            bool        fNumbered  = pDbgInfo->aEntries[iDbgEntry].Label.uData != 0;
                             switch ((IEMNATIVELABELTYPE)pDbgInfo->aEntries[iDbgEntry].Label.enmLabel)
                             {
Index: /trunk/src/VBox/VMM/include/IEMN8veRecompiler.h
===================================================================
--- /trunk/src/VBox/VMM/include/IEMN8veRecompiler.h	(revision 101567)
+++ /trunk/src/VBox/VMM/include/IEMN8veRecompiler.h	(revision 101568)
@@ -660,4 +660,7 @@
  * This will reallocate the buffer if needed and allowed.
  *
+ * @note    Always use IEMNATIVE_ASSERT_INSTR_BUF_ENSURE when done to check the
+ *          allocation size.
+ *
  * @returns Pointer to the instruction output buffer on success, NULL on
  *          failure.
@@ -2231,10 +2234,11 @@
 # error "Port me!"
 #endif
-    return off;
-}
-
-
-/**
- * Emits a jump to @a idxLabel con the condition that bit@a iBitNo _is_ _set_ in
+    IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
+    return off;
+}
+
+
+/**
+ * Emits a jump to @a idxLabel on the condition that bit @a iBitNo _is_ _set_ in
  * @a iGprSrc.
  *
@@ -2249,5 +2253,5 @@
 
 /**
- * Emits a jump to @a idxLabel con the condition that bit@a iBitNo _is_ _not_
+ * Emits a jump to @a idxLabel on the condition that bit @a iBitNo _is_ _not_
  * _set_ in @a iGprSrc.
  *
@@ -2262,4 +2266,110 @@
 
 /**
+ * Emits a test for any of the bits from @a fBits in @a iGprSrc, setting CPU
+ * flags accordingly.
+ */
+DECLINLINE(uint32_t) iemNativeEmitTestAnyBitsInGpr(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t iGprSrc, uint64_t fBits)
+{
+    Assert(fBits != 0);
+#ifdef RT_ARCH_AMD64
+
+    if (fBits >= UINT32_MAX)
+    {
+        uint8_t iTmpReg = iemNativeRegAllocTmpImm(pReNative, &off, fBits);
+        AssertReturn(iTmpReg < RT_ELEMENTS(pReNative->Core.aHstRegs), UINT32_MAX);
+
+        /* test Ev,Gv */
+        uint8_t * const pbCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 5);
+        AssertReturn(pbCodeBuf, UINT32_MAX);
+        pbCodeBuf[off++] = X86_OP_REX_W | (iGprSrc < 8 ? 0 : X86_OP_REX_R) | (iTmpReg < 8 ? 0 : X86_OP_REX_B);
+        pbCodeBuf[off++] = 0x85;
+        pbCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, iGprSrc & 8, iTmpReg & 7);
+
+        iemNativeRegFreeTmpImm(pReNative, iTmpReg);
+    }
+    else
+    {
+        /* test Eb, imm8 or test Ev, imm32 */
+        uint8_t * const pbCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 7);
+        AssertReturn(pbCodeBuf, UINT32_MAX);
+        if (iGprSrc >= 8)
+            pbCodeBuf[off++] = X86_OP_REX_B;
+        if (fBits <= UINT8_MAX)
+        {
+            pbCodeBuf[off++] = 0xf6;
+            pbCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, 0, iGprSrc & 7);
+            pbCodeBuf[off++] = (uint8_t)fBits;
+        }
+        else
+        {
+            pbCodeBuf[off++] = 0xf7;
+            pbCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, 0, iGprSrc & 7);
+            pbCodeBuf[off++] = RT_BYTE1(fBits);
+            pbCodeBuf[off++] = RT_BYTE2(fBits);
+            pbCodeBuf[off++] = RT_BYTE3(fBits);
+            pbCodeBuf[off++] = RT_BYTE4(fBits);
+        }
+    }
+
+#elif defined(RT_ARCH_ARM64)
+
+    if (false)
+    {
+        /** @todo figure out how to work the immr / N:imms constants. */
+    }
+    else
+    {
+        uint8_t iTmpReg = iemNativeRegAllocTmpImm(pReNative, &off, fBits);
+        AssertReturn(iTmpReg < RT_ELEMENTS(pReNative->Core.aHstRegs), UINT32_MAX);
+
+        /* ands Zr, iGprSrc, iTmpReg */
+        uint32_t * const pu32CodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1);
+        AssertReturn(pu32CodeBuf, UINT32_MAX);
+        pu32CodeBuf[off++] = Armv8A64MkInstrAnds(ARMV8_A64_REG_XZR, iGprSrc, iTmpReg);
+
+        iemNativeRegFreeTmpImm(pReNative, iTmpReg);
+    }
+
+#else
+# error "Port me!"
+#endif
+    IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
+    return off;
+}
+
+
+/**
+ * Emits a jump to @a idxLabel on the condition _any_ of the bits in @a fBits
+ * are set in @a iGprSrc.
+ */
+DECLINLINE(uint32_t) iemNativeEmitTestAnyBitsInGprAndJmpToLabelIfAnySet(PIEMRECOMPILERSTATE pReNative, uint32_t off,
+                                                                        uint8_t iGprSrc, uint64_t fBits, uint32_t idxLabel)
+{
+    Assert(fBits); Assert(!RT_IS_POWER_OF_TWO(fBits));
+
+    off = iemNativeEmitTestAnyBitsInGpr(pReNative, off, iGprSrc, fBits);
+    off = iemNativeEmitJnzToLabel(pReNative, off, idxLabel);
+
+    return off;
+}
+
+
+/**
+ * Emits a jump to @a idxLabel on the condition _none_ of the bits in @a fBits
+ * are set in @a iGprSrc.
+ */
+DECLINLINE(uint32_t) iemNativeEmitTestAnyBitsInGprAndJmpToLabelIfNoneSet(PIEMRECOMPILERSTATE pReNative, uint32_t off,
+                                                                         uint8_t iGprSrc, uint64_t fBits, uint32_t idxLabel)
+{
+    Assert(fBits); Assert(!RT_IS_POWER_OF_TWO(fBits));
+
+    off = iemNativeEmitTestAnyBitsInGpr(pReNative, off, iGprSrc, fBits);
+    off = iemNativeEmitJzToLabel(pReNative, off, idxLabel);
+
+    return off;
+}
+
+
+/**
  * Emits a call to a 64-bit address.
  */
