78b95ac2d80dc9eeb5315c62e1454033cb55bfd5
[sb-simd.git] / scratch / sse2.lisp
blob78b95ac2d80dc9eeb5315c62e1454033cb55bfd5
1 ;;; From sb-devel post by Christophe Rhodes
2 (in-package :cl-user)
4 (declaim (inline fixnum/vector+))
5 (defun fixnum/vector+ (vector1 vector2)
6 (let ((result (make-array (length vector1) :element-type 'fixnum)))
7 (dotimes (i 1000000)
8 (declare (fixnum i))
9 (%vector+ result vector1 vector2))
10 result))
12 (defun foo ()
13 (declare (optimize (speed 3) (safety 0)))
14 (let ((x (make-array 1000 :element-type 'fixnum
15 :initial-contents (loop for x fixnum from 0 to 999 collect x)))
16 (y (make-array 1000 :element-type 'fixnum
17 :initial-contents (loop for x fixnum from 0 to 999 collect x))))
18 (fixnum/vector+ x y)))
20 (defun bar ()
21 (declare (optimize (speed 3) (safety 0)))
22 (let ((x (make-array 1000 :element-type 'fixnum
23 :initial-contents (loop for x fixnum from 0 to 999 collect x)))
24 (y (make-array 1000 :element-type 'fixnum
25 :initial-contents (loop for x fixnum from 0 to 999 collect x))))
26 (let ((result (make-array 1000 :element-type 'fixnum)))
27 (dotimes (j 1000000)
28 (declare (fixnum j))
29 (loop for tx across x
30 for ty across y
31 for i fixnum upfrom 0
32 do (setf (aref result i) (+ tx ty))))
33 result)))