check bad reg combination of gather
diff --git a/test/address.cpp b/test/address.cpp
index 8012589..e713b5a 100644
--- a/test/address.cpp
+++ b/test/address.cpp
@@ -31,7 +31,7 @@
 		"xmm3 * 8 + edi + 123",
 		"xmm2 * 2 + 5",
 		"eax + xmm0",
-		"esp + xmm4",
+		"esp + xmm2",
 	};
 	const char *vm32yTbl[] = {
 		"ymm0",
@@ -42,7 +42,7 @@
 		"ymm3 * 8 + edi + 123",
 		"ymm2 * 2 + 5",
 		"eax + ymm0",
-		"esp + ymm4",
+		"esp + ymm2",
 	};
 	genVsibSub(isJIT, "vgatherdpd", vm32xTbl, NUM_OF_ARRAY(vm32xTbl));
 	genVsibSub(isJIT, "vgatherqpd", vm32yTbl, NUM_OF_ARRAY(vm32yTbl));
diff --git a/xbyak/xbyak.h b/xbyak/xbyak.h
index bf92ae4..ea67ca8 100644
--- a/xbyak/xbyak.h
+++ b/xbyak/xbyak.h
@@ -2261,7 +2261,11 @@
 			}
 			if (!isOK) XBYAK_THROW(ERR_BAD_VSIB_ADDRESSING)
 		}
-		opAVX_X_X_XM(isAddrYMM ? Ymm(x1.getIdx()) : x1, isAddrYMM ? Ymm(x2.getIdx()) : x2, addr, type, code);
+		int i1 = x1.getIdx();
+		int i2 = regExp.getIndex().getIdx();
+		int i3 = x2.getIdx();
+		if (i1 == i2 || i1 == i3 || i2 == i3) XBYAK_THROW(ERR_BAD_COMBINATION);
+		opAVX_X_X_XM(isAddrYMM ? Ymm(i1) : x1, isAddrYMM ? Ymm(i3) : x2, addr, type, code);
 	}
 	enum {
 		xx_yy_zz = 0,