[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 1ece474c69c 1/2: Slight funcall_subr optimisation
From: |
Mattias Engdegård |
Subject: |
master 1ece474c69c 1/2: Slight funcall_subr optimisation |
Date: |
Fri, 22 Dec 2023 09:26:21 -0500 (EST) |
branch: master
commit 1ece474c69cfcf6f8ef14d54e469eb387a7a6983
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
Slight funcall_subr optimisation
* src/eval.c (funcall_subr): Help the compiler by reducing aliasing
problems, and compensate for a missed-optimisation bug in LLVM where
switches sometimes forget to use variable range information (reported
in https://github.com/llvm/llvm-project/issues/76085).
---
src/eval.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/src/eval.c b/src/eval.c
index 5c9052cb9ab..b3d3fc3132b 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -3033,21 +3033,21 @@ funcall_subr (struct Lisp_Subr *subr, ptrdiff_t
numargs, Lisp_Object *args)
if (numargs >= subr->min_args)
{
/* Conforming call to finite-arity subr. */
- if (numargs <= subr->max_args
- && subr->max_args <= 8)
+ ptrdiff_t maxargs = subr->max_args;
+ if (numargs <= maxargs && maxargs <= 8)
{
Lisp_Object argbuf[8];
Lisp_Object *a;
- if (numargs < subr->max_args)
+ if (numargs < maxargs)
{
- eassume (subr->max_args <= ARRAYELTS (argbuf));
+ eassume (maxargs <= ARRAYELTS (argbuf));
a = argbuf;
memcpy (a, args, numargs * word_size);
- memclear (a + numargs, (subr->max_args - numargs) * word_size);
+ memclear (a + numargs, (maxargs - numargs) * word_size);
}
else
a = args;
- switch (subr->max_args)
+ switch (maxargs)
{
case 0:
return subr->function.a0 ();
@@ -3069,14 +3069,12 @@ funcall_subr (struct Lisp_Subr *subr, ptrdiff_t
numargs, Lisp_Object *args)
case 8:
return subr->function.a8 (a[0], a[1], a[2], a[3], a[4], a[5],
a[6], a[7]);
- default:
- emacs_abort (); /* Can't happen. */
}
+ eassume (false); /* In case the compiler is too stupid. */
}
/* Call to n-adic subr. */
- if (subr->max_args == MANY
- || subr->max_args > 8)
+ if (maxargs == MANY || maxargs > 8)
return subr->function.aMANY (numargs, args);
}