Transform n-ary comparisons to a chain of binary comparisons in the
Lisp optimiser instead of in codegen, to allow for subsequent
optimisations. This generalises the transform, so that
(< 1 X 10) -> (let ((x X)) (and (< 1 x) (< x 10)))
where (< 1 x) is then flipped to (> x 1) in codegen since it's
slightly more efficient to have the constant argument last. Arguments
that are neither constants nor variables are given temporary bindings.
This results in about 2× speedup for 3-ary comparisons of fixnums with
nontrivial arguments, and also improves the code slightly for binary
comparisons with a constant first argument.
* lisp/emacs-lisp/byte-opt.el (byte-opt--nary-comparison): New,
set as the `byte-optimizer` property for =, <, <=, >, and >=.
* lisp/emacs-lisp/bytecomp.el (byte-compile-and-folded):
Rename to...
(byte-compile-cmp): ...and rewrite.