From e302493800a74b0498dd3e2d8522a8de28d33766 Mon Sep 17 00:00:00 2001 From: John Lorentzson Date: Thu, 31 Jul 2025 12:49:50 +0200 Subject: [PATCH] Some cleanup in compilation of IR-IF to asm --- .../backend/code-generator.lisp | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/user-side-compiler/backend/code-generator.lisp b/user-side-compiler/backend/code-generator.lisp index 8701434..f884ad9 100644 --- a/user-side-compiler/backend/code-generator.lisp +++ b/user-side-compiler/backend/code-generator.lisp @@ -208,21 +208,21 @@ is the responsibility of the pre-assembly compilation step." (emit-load-data (input inst)) (let ((prev-is-test-p (eql (strategy (allocation-details (input inst))) :branch))) - (if prev-is-test-p - ;; If previous was a test, this instruction will be skipped if the - ;; test succeeds and we fall through to the THEN case. If it fails, - ;; this instruction executes, which jumps to the ELSE case. - (emit-asm-instruction :opcode #x4C - :operand else-iblock - :byte-length 3) - ;; If the input is a bool value, we have to actually do some work. - (progn - ;; BNE +3, if it's Not Equal (zero), then it's true, so we skip... - (emit-asm-instruction :opcode #xD0 :operand 3 :byte-length 2) - ;; ...the jump to the ELSE case. - (emit-asm-instruction :opcode #x4C - :operand else-iblock - :byte-length 3)))) + (cond (prev-is-test-p + ;; If previous was a test, this instruction will be skipped if the + ;; test succeeds and we fall through to the THEN case. If it fails, + ;; this instruction executes, which jumps to the ELSE case. + (emit-asm-instruction :opcode #x4C + :operand else-iblock + :byte-length 3)) + (t + ;; If the input is a bool value, we have to actually do some work. + ;; BNE +3, if it's Not Equal (zero), then it's true, so we skip... + (emit-asm-instruction :opcode #xD0 :operand 3 :byte-length 2) + ;; ...the jump to the ELSE case. + (emit-asm-instruction :opcode #x4C + :operand else-iblock + :byte-length 3)))) (setf *last-instruction* :branch))) (defun emit-branch-test-code (inputs output branch-opcodes)