diff options
author | Ludovic Courtès <ludo@gnu.org> | 2021-09-20 23:27:39 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2021-09-20 23:27:39 +0200 |
commit | 74abae04aa68dc18676bd84c4a73324b0613475d (patch) | |
tree | a7fec81b6769b42ed91142487ee90196f64cca49 /module/language/tree-il/compile-bytecode.scm | |
parent | 330c6ea83f492672578b62d0683acbb532d1a5d9 (diff) | |
download | guile-74abae04aa68dc18676bd84c4a73324b0613475d.tar.gz |
Baseline compiler no longer swaps rsh/lsh when transforming ash calls.
Reported by Marius Bakke <marius@gnu.org>
at <https://issues.guix.gnu.org/50696>.
Previously, the baseline compiler would incorrectly emit a right shift
when for, say, (ash x 2), and a left shift for (ash x -2).
* module/language/tree-il/compile-bytecode.scm (canonicalize): When Y is
negative, emit 'rsh', not 'lsh'.
* test-suite/tests/numbers.test ("ash at -O1"): New test.
Diffstat (limited to 'module/language/tree-il/compile-bytecode.scm')
-rw-r--r-- | module/language/tree-il/compile-bytecode.scm | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/module/language/tree-il/compile-bytecode.scm b/module/language/tree-il/compile-bytecode.scm index 551ae68e9..87d903c10 100644 --- a/module/language/tree-il/compile-bytecode.scm +++ b/module/language/tree-il/compile-bytecode.scm @@ -461,8 +461,8 @@ ;; Transform "ash" to lsh / rsh. (($ <primcall> src 'ash (x ($ <const> src* (? exact-integer? y)))) (if (negative? y) - (make-primcall src 'lsh (list x (make-const src* (- y)))) - (make-primcall src 'rsh (list x (make-const src* y))))) + (make-primcall src 'rsh (list x (make-const src* (- y)))) + (make-primcall src 'lsh (list x (make-const src* y))))) ;; (throw key subr msg (list x) (list x)) (($ <primcall> src 'throw |