> On Wed, Mar 2, 2011 at 9:40 PM, Alexander Gavrilov 
> <angavri...@gmail.com>wrote:
> > As an alternative, if there is a way to fuse the constant with
> > the unboxing operation, the unboxed value can probably be represented
> > as an expression using a couple of C intrinsic functions.
> >
> 
> ... this might be a better solution. ECL currently provides various hooks
> for inlining functions. One I like quite much is the use of compiler macros.
> You could replace current sse compilations with compiler macros that inline
> the constants as C expressions.

I've implemented a c-inline based representation for SSE constants
(code inspired by the optimizable constants feature). The only downside
I see is that if the constant happens to actually be used in boxed form
(e.g. in a macro or something), it will likely be boxed every time
it is evaluated instead of once.

Patch attached, together with two other minor tweaks.

Alexander

P.S. When I was writing that static constant code I was still trying
     hard not to use the cast intrinsics. Now that I'm already using
     them, there is no point in avoiding them only for the constants.
From e990f71a273f00d4a86add9e39f9d7e005dc809e Mon Sep 17 00:00:00 2001
From: Alexander Gavrilov <angavri...@gmail.com>
Date: Sat, 5 Mar 2011 21:05:25 +0300
Subject: [PATCH 1/3] Make THE actually produce the warning if the intersection is empty.

---
 src/cmp/cmpspecial.lsp |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/cmp/cmpspecial.lsp b/src/cmp/cmpspecial.lsp
index acd27d8..48f00ea 100644
--- a/src/cmp/cmpspecial.lsp
+++ b/src/cmp/cmpspecial.lsp
@@ -27,7 +27,8 @@
   (let* ((form (c1expr (second args)))
 	 (the-type (first args))
 	 type)
-    (if (setf type (values-type-and the-type (c1form-primary-type form)))
+    (setf type (values-type-and the-type (c1form-primary-type form)))
+    (if (values-type-primary-type type)
         (setf (c1form-type form) type)
       (cmpwarn "Type mismatch was found in ~s." (cons 'THE args)))
     form))
-- 
1.7.2.3

From e25e2ec1b25eb06927355cb9155b96d7051f2fe6 Mon Sep 17 00:00:00 2001
From: Alexander Gavrilov <angavri...@gmail.com>
Date: Sat, 5 Mar 2011 21:11:58 +0300
Subject: [PATCH 2/3] Use a c-inline transformation to represent SSE constants in code.

---
 src/cmp/cmpct.lsp |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/src/cmp/cmpct.lsp b/src/cmp/cmpct.lsp
index e35f8da..8276eeb 100644
--- a/src/cmp/cmpct.lsp
+++ b/src/cmp/cmpct.lsp
@@ -40,12 +40,29 @@
    ((typep val 'LONG-FLOAT)
     (make-c1form* 'LOCATION :type 'LONG-FLOAT
 		  :args (list 'LONG-FLOAT-VALUE val (add-object val))))
+   #+sse2
+   ((typep val 'EXT:SSE-PACK)
+    (c1constant-value/sse val))
    (always
     (make-c1form* 'LOCATION :type (object-type val)
 		  :args (add-object val)))
    (only-small-values nil)
    (t nil)))
 
+#+sse2
+(defun c1constant-value/sse (value)
+  (let* ((bytes (ext:sse-pack-to-vector value '(unsigned-byte 8)))
+         (elt-type (ext:sse-pack-element-type value)))
+    (multiple-value-bind (wrapper rtype)
+        (case elt-type
+          (single-float (values "_mm_castsi128_ps" :float-sse-pack))
+          (double-float (values "_mm_castsi128_pd" :double-sse-pack))
+          (otherwise    (values ""                 :int-sse-pack)))
+      (c1expr `(c-inline () () ,rtype
+                         ,(format nil "~A(_mm_setr_epi8(~{~A~^,~}))"
+                                  wrapper (coerce bytes 'list))
+                         :one-liner t :side-effects nil)))))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;
 ;;; KNOWN OPTIMIZABLE CONSTANTS
-- 
1.7.2.3

From d8bff7e8f900c6b2a6a763f666c3d62c92950454 Mon Sep 17 00:00:00 2001
From: Alexander Gavrilov <angavri...@gmail.com>
Date: Sat, 5 Mar 2011 21:20:44 +0300
Subject: [PATCH 3/3] Add errno.h to unixsys.d

---
 src/c/unixsys.d |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/c/unixsys.d b/src/c/unixsys.d
index 8af6b61..545ab83 100755
--- a/src/c/unixsys.d
+++ b/src/c/unixsys.d
@@ -17,6 +17,7 @@
 
 #include <stdlib.h>
 #include <string.h>
+#include <errno.h>
 #include <stdio.h>
 #include <fcntl.h>
 #include <signal.h> /* to see whether we have SIGCHLD */
-- 
1.7.2.3

------------------------------------------------------------------------------
What You Don't Know About Data Connectivity CAN Hurt You
This paper provides an overview of data connectivity, details
its effect on application quality, and explores various alternative
solutions. http://p.sf.net/sfu/progress-d2d
_______________________________________________
Ecls-list mailing list
Ecls-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ecls-list

Reply via email to