From 0d225f55055cbbc6e1d71f66e560049a5cadadfb Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Wed, 6 May 2020 12:11:14 -0600 Subject: [PATCH] x86_64: fix popcount without POPCNT Commit 68b2f597ec moved the argument from RDI to RCX, but the `popcount-slow` function wasn't updated. Related to racket/racket#3150 original commit: 80ffa4eea197a885cd647fcfb76dda720b64781d --- s/cpnanopass.ss | 2 +- s/x86_64.ss | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/s/cpnanopass.ss b/s/cpnanopass.ss index c91d1056ad..bd38f64418 100644 --- a/s/cpnanopass.ss +++ b/s/cpnanopass.ss @@ -13670,7 +13670,7 @@ ,(constant-case architecture [(x86_64) `(seq - (set! ,%rax (inline ,(make-info-inline) ,%popcount ,%rdi)) + (set! ,%rax (inline ,(make-info-inline) ,%popcount ,%rcx)) (asm-c-return ,null-info ,%rax))] [else ;; Generate anything, since this should not get called diff --git a/s/x86_64.ss b/s/x86_64.ss index 5c187b9915..9cb5b3e869 100644 --- a/s/x86_64.ss +++ b/s/x86_64.ss @@ -1642,9 +1642,9 @@ (asm-helper-call code* target dest-rax)] [else ;; Used for the body of `popcount-slow`. - ;; This is the sequence generated by LLVM's __builtin_popcountl() - ;; __builtin_popcountl() intrinsic, but with pushes and pops - ;; to save used registers other than the result register %rax. + ;; This is the sequence generated by LLVM's __builtin_popcountl(), + ;; but with pushes and pops to save used registers other than the + ;; result register %rax. (emit-literal-code (op dest-rax src-rcx code*) 51 ; pushq %rcx 57 ; pushq %rdi