diff --git a/common/x86/x86inc.asm b/common/x86/x86inc.asm
index 0750b0a4794e6c44c0c1a81dc25508e324153f8c..4cf82118d85df94fabdded2783c85cc5c08fdc83 100644
--- a/common/x86/x86inc.asm
+++ b/common/x86/x86inc.asm
@@ -245,6 +245,16 @@ DECLARE_REG_TMP_SIZE 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14
 %endif
 %endmacro
 
+; Repeats an instruction/operation for multiple arguments.
+; Example usage: "REPX {psrlw x, 8}, m0, m1, m2, m3"
+%macro REPX 2-* ; operation, args
+    %xdefine %%f(x) %1
+    %rep %0 - 1
+        %rotate 1
+        %%f(%1)
+    %endrep
+%endmacro
+
 %macro PUSH 1
     push %1
     %ifidn rstk, rsp