aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias EngdegÄrd2023-11-21 11:23:57 +0100
committerMattias EngdegÄrd2023-12-22 14:13:23 +0100
commit1ece474c69cfcf6f8ef14d54e469eb387a7a6983 (patch)
tree9ab0e8b55bd83cbd32196174f4a005a47e3af07e /src
parentc638a40d88f6ca105babbf9078b086491b649797 (diff)
downloademacs-1ece474c69cfcf6f8ef14d54e469eb387a7a6983.tar.gz
emacs-1ece474c69cfcf6f8ef14d54e469eb387a7a6983.zip
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).
Diffstat (limited to 'src')
-rw-r--r--src/eval.c18
1 files 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)
3033 if (numargs >= subr->min_args) 3033 if (numargs >= subr->min_args)
3034 { 3034 {
3035 /* Conforming call to finite-arity subr. */ 3035 /* Conforming call to finite-arity subr. */
3036 if (numargs <= subr->max_args 3036 ptrdiff_t maxargs = subr->max_args;
3037 && subr->max_args <= 8) 3037 if (numargs <= maxargs && maxargs <= 8)
3038 { 3038 {
3039 Lisp_Object argbuf[8]; 3039 Lisp_Object argbuf[8];
3040 Lisp_Object *a; 3040 Lisp_Object *a;
3041 if (numargs < subr->max_args) 3041 if (numargs < maxargs)
3042 { 3042 {
3043 eassume (subr->max_args <= ARRAYELTS (argbuf)); 3043 eassume (maxargs <= ARRAYELTS (argbuf));
3044 a = argbuf; 3044 a = argbuf;
3045 memcpy (a, args, numargs * word_size); 3045 memcpy (a, args, numargs * word_size);
3046 memclear (a + numargs, (subr->max_args - numargs) * word_size); 3046 memclear (a + numargs, (maxargs - numargs) * word_size);
3047 } 3047 }
3048 else 3048 else
3049 a = args; 3049 a = args;
3050 switch (subr->max_args) 3050 switch (maxargs)
3051 { 3051 {
3052 case 0: 3052 case 0:
3053 return subr->function.a0 (); 3053 return subr->function.a0 ();
@@ -3069,14 +3069,12 @@ funcall_subr (struct Lisp_Subr *subr, ptrdiff_t numargs, Lisp_Object *args)
3069 case 8: 3069 case 8:
3070 return subr->function.a8 (a[0], a[1], a[2], a[3], a[4], a[5], 3070 return subr->function.a8 (a[0], a[1], a[2], a[3], a[4], a[5],
3071 a[6], a[7]); 3071 a[6], a[7]);
3072 default:
3073 emacs_abort (); /* Can't happen. */
3074 } 3072 }
3073 eassume (false); /* In case the compiler is too stupid. */
3075 } 3074 }
3076 3075
3077 /* Call to n-adic subr. */ 3076 /* Call to n-adic subr. */
3078 if (subr->max_args == MANY 3077 if (maxargs == MANY || maxargs > 8)
3079 || subr->max_args > 8)
3080 return subr->function.aMANY (numargs, args); 3078 return subr->function.aMANY (numargs, args);
3081 } 3079 }
3082 3080