From 55c1bc380ab0ace1319dfaac6ffa696d2ba00f06 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Tue, 13 Aug 2024 13:40:09 +0200 Subject: More thorough lowering of lognot to CPS * module/language/tree-il/compile-cps.scm (canonicalize): Lower to a logxor with -1. Origin: upstream, commit 7aa4cfa9ded582952e16235d8aa634ada22febf2 --- module/language/tree-il/compile-cps.scm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/module/language/tree-il/compile-cps.scm b/module/language/tree-il/compile-cps.scm index e1cf8c297..ea5be8aa8 100644 --- a/module/language/tree-il/compile-cps.scm +++ b/module/language/tree-il/compile-cps.scm @@ -2385,9 +2385,13 @@ integer." ;; if type folding can't prove Y to be an exact integer, then DCE ;; would have to leave it in the program for its possible ;; effects. - (($ src 'logand (x ($ _ 'lognot (y)))) + (($ src 'lognot (x)) + (make-primcall src 'logxor (list x (make-const src -1)))) + (($ src 'logand + (x ($ _ 'logxor (y ($ _ -1))))) (make-primcall src 'logsub (list x y))) - (($ src 'logand (($ _ 'lognot (y)) x)) + (($ src 'logand + (($ _ 'logxor (y ($ _ -1))) x)) (make-primcall src 'logsub (list x y))) (($ src 'throw ())