GH-135379: Support limited scalar replacement for replicated uops in the JIT code generator. (GH-135563)

* Use it to support efficient specializations of COPY and SWAP in the JIT.
This commit is contained in:
Mark Shannon 2025-06-17 13:43:09 +01:00 committed by GitHub
parent a9e66a7c50
commit 8dd8b5c2f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 313 additions and 198 deletions

View file

@ -6763,12 +6763,44 @@
break;
}
case _COPY_1: {
_PyStackRef bottom;
_PyStackRef top;
bottom = stack_pointer[-1];
top = PyStackRef_DUP(bottom);
stack_pointer[0] = top;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
case _COPY_2: {
_PyStackRef bottom;
_PyStackRef top;
bottom = stack_pointer[-2];
top = PyStackRef_DUP(bottom);
stack_pointer[0] = top;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
case _COPY_3: {
_PyStackRef bottom;
_PyStackRef top;
bottom = stack_pointer[-3];
top = PyStackRef_DUP(bottom);
stack_pointer[0] = top;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
case _COPY: {
_PyStackRef bottom;
_PyStackRef top;
oparg = CURRENT_OPARG();
bottom = stack_pointer[-1 - (oparg-1)];
assert(oparg > 0);
top = PyStackRef_DUP(bottom);
stack_pointer[0] = top;
stack_pointer += 1;
@ -6808,6 +6840,32 @@
break;
}
case _SWAP_2: {
_PyStackRef top;
_PyStackRef bottom;
top = stack_pointer[-1];
bottom = stack_pointer[-2];
_PyStackRef temp = bottom;
bottom = top;
top = temp;
stack_pointer[-2] = bottom;
stack_pointer[-1] = top;
break;
}
case _SWAP_3: {
_PyStackRef top;
_PyStackRef bottom;
top = stack_pointer[-1];
bottom = stack_pointer[-3];
_PyStackRef temp = bottom;
bottom = top;
top = temp;
stack_pointer[-3] = bottom;
stack_pointer[-1] = top;
break;
}
case _SWAP: {
_PyStackRef top;
_PyStackRef bottom;
@ -6817,7 +6875,6 @@
_PyStackRef temp = bottom;
bottom = top;
top = temp;
assert(oparg >= 2);
stack_pointer[-2 - (oparg-2)] = bottom;
stack_pointer[-1] = top;
break;