From 285d1d9603e8b02d43d78412c335c0ca9a31111a Mon Sep 17 00:00:00 2001 From: Raymond Toy Date: Sun, 19 Apr 2020 10:33:27 -0700 Subject: [PATCH] Refine features to include sse4 for popcnt popcnt is part of sse4, not sse3/ssse3, so add feature detection for sse4 to enable use of this instruciton. sse4 and ppcnt was first available in the Nehalem architecture, Nov 2008 in the first gen of Core i7 and i5 processors. The oldest machines I have access to date from 2011. Also remove :ssse3 because we don't currently define or use any ssse3 instructions. Add a bit of documentation about popcnt. Setup CI to build with a bootstrap file to get these instructions. --- .gitlab-ci.yml | 2 +- src/bootfiles/21d/boot-2020-04.lisp | 4 +++- src/code/x86-vm.lisp | 11 ++++++++++- src/compiler/x86/arith.lisp | 2 +- src/compiler/x86/insts.lisp | 1 + 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ff65c4d13..a85520aa0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ variables: download_url: "https://common-lisp.net/project/cmucl/downloads/snapshots/2020/04" version: "2020-04-x86" - bootstrap: "" + bootstrap: "-B boot-2020-04" linux-runner: tags: diff --git a/src/bootfiles/21d/boot-2020-04.lisp b/src/bootfiles/21d/boot-2020-04.lisp index 3fcc222a7..474597cbe 100644 --- a/src/bootfiles/21d/boot-2020-04.lisp +++ b/src/bootfiles/21d/boot-2020-04.lisp @@ -2,4 +2,6 @@ #+x86 (pushnew :sse3 *features*) #+x86 -(pushnew :ssse3 *features*) \ No newline at end of file +(pushnew :ssse3 *features*) +#+x86 +(pushnew :sse4 *features*) diff --git a/src/code/x86-vm.lisp b/src/code/x86-vm.lisp index e58d6cc9b..3dbc79420 100644 --- a/src/code/x86-vm.lisp +++ b/src/code/x86-vm.lisp @@ -42,12 +42,21 @@ (setf *features* (delete :x87 *features*)) (sys:register-lisp-feature :sse2)) +#+sse3 +(progn + (setf *features* (delete :x87 *features*)) + (sys:register-lisp-feature :sse3)) + #+ssse3 (progn (setf *features* (delete :x87 *features*)) - (sys:register-lisp-feature :sse3) (sys:register-lisp-feature :ssse3)) +#+sse4 +(progn + (setf *features* (delete :x87 *features*)) + (sys:register-lisp-feature :sse4)) + #+(or darwin linux) (sys:register-lisp-runtime-feature :relocatable-stacks) diff --git a/src/compiler/x86/arith.lisp b/src/compiler/x86/arith.lisp index e5dd7d425..ccdda0816 100644 --- a/src/compiler/x86/arith.lisp +++ b/src/compiler/x86/arith.lisp @@ -964,7 +964,7 @@ (:arg-types unsigned-num) (:results (result :scs (unsigned-reg))) (:result-types positive-fixnum) - (:guard (backend-featurep :sse3)) + (:guard (backend-featurep :sse4)) (:generator 2 (inst popcnt result arg))) diff --git a/src/compiler/x86/insts.lisp b/src/compiler/x86/insts.lisp index 0964ea05c..e57e5e695 100644 --- a/src/compiler/x86/insts.lisp +++ b/src/compiler/x86/insts.lisp @@ -3201,6 +3201,7 @@ (define-regular-sse-inst paddq #x66 #xd4) ) +;; SSE4 instruction (define-instruction popcnt (segment dst src) (:printer ext-reg-reg/mem ((prefix #xf3) (op #xb8))) -- GitLab