[Ecls-list] logior/ash and fixnum inlining

Matthew Mondor mm_lists at pulsar-zone.net
Tue Jul 26 22:19:36 UTC 2011


On Tue, 26 Jul 2011 16:10:33 -0400
Matthew Mondor <mm_lists at pulsar-zone.net> wrote:

> Well here is some slight progress; I remembered that + worked better in
> pairs and thought I'd also try with LOGIOR.  ASH calls however are
> still implicit even if the parameters consist of a pair of fixnums.

I could resume some more testing;

And the following works.  I assume that ASH calls are not getting
inlined in relation to the comment in the code about undefined C
compiler behaviour in some circumstances, which would require the
inlining code to be more complex to only inline in appropriate
circumstances... and using c::shift<< makes it easier in this case.


(defmacro with-fixnum-reduce ((op) &rest args)
  (reduce #'(lambda (a b)
	      `(the fixnum (,op (the fixnum ,a) (the fixnum ,b))))
	  args))

(defun address-fixnum (addr)
  (declare (optimize (speed 3) (safety 0) (debug 0))
	   (type (simple-array fixnum 4) addr))
  (with-fixnum-reduce (logior)
    (the fixnum (c::shift<< (the fixnum (aref addr 0)) 24))
    (the fixnum (c::shift<< (the fixnum (aref addr 1)) 16))
    (the fixnum (c::shift<< (the fixnum (aref addr 2)) 8))
    (the fixnum (aref addr 3))))


/*	function definition for ADDRESS-FIXNUM                        */
/*	optimize speed 3, debug 0, space 0, safety 0                  */
static cl_object L3address_fixnum(cl_object V1)
{
    VT4 VLEX4 CLSR4 STCK4 const cl_env_ptr cl_env_copy = ecl_process_env();
    cl_object value0;
  TTL:
    {
        cl_fixnum V2;
        V2 = (cl_fixnum) ((V1)->vector.self.i32[0]);
        {
            cl_fixnum V3;
            V3 = ((V2) << (24));
            {
                cl_fixnum V4;
                V4 = (cl_fixnum) ((V1)->vector.self.i32[1]);
                {
                    cl_fixnum V5;
                    V5 = ((V4) << (16));
                    {
                        cl_fixnum V6;
                        V6 = ((V3) | (V5));
                        {
                            cl_fixnum V7;
                            V7 = (cl_fixnum) ((V1)->vector.self.i32[2]);
                            {
                                cl_fixnum V8;
                                V8 = ((V7) << (8));
                                {
                                    cl_fixnum V9;
                                    V9 = ((V6) | (V8));
                                    {
                                        cl_fixnum V10;
                                        V10 =
                                            (cl_fixnum) ((V1)->vector.self.
                                                         i32[3]);
                                        value0 =
                                            MAKE_FIXNUM(((V9) | (V10)));
                                        cl_env_copy->nvalues = 1;
                                        return value0;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}


00000990 <L3address_fixnum>:
 990:   55                      push   %ebp
 991:   89 e5                   mov    %esp,%ebp
 993:   83 ec 08                sub    $0x8,%esp
 996:   8b 45 08                mov    0x8(%ebp),%eax
 999:   89 1c 24                mov    %ebx,(%esp)
 99c:   89 74 24 04             mov    %esi,0x4(%esp)
 9a0:   e8 90 04 00 00          call   e35 <__i686.get_pc_thunk.bx>
 9a5:   81 c3 c7 07 00 00       add    $0x7c7,%ebx
 9ab:   8b 48 10                mov    0x10(%eax),%ecx
 9ae:   8b 01                   mov    (%ecx),%eax
 9b0:   8b 51 04                mov    0x4(%ecx),%edx
 9b3:   8b 71 08                mov    0x8(%ecx),%esi
 9b6:   c1 e0 18                shl    $0x18,%eax
 9b9:   c1 e2 10                shl    $0x10,%edx
 9bc:   09 d0                   or     %edx,%eax
 9be:   8b 51 0c                mov    0xc(%ecx),%edx
 9c1:   c1 e6 08                shl    $0x8,%esi
 9c4:   09 d0                   or     %edx,%eax
 9c6:   09 c6                   or     %eax,%esi
 9c8:   e8 b3 fe ff ff          call   880 <ecl_process_env at plt>
 9cd:   c1 e6 02                shl    $0x2,%esi
 9d0:   83 ce 03                or     $0x3,%esi
 9d3:   c7 40 04 01 00 00 00    movl   $0x1,0x4(%eax)
 9da:   89 f0                   mov    %esi,%eax
 9dc:   8b 1c 24                mov    (%esp),%ebx
 9df:   8b 74 24 04             mov    0x4(%esp),%esi
 9e3:   89 ec                   mov    %ebp,%esp
 9e5:   5d                      pop    %ebp
 9e6:   c3                      ret    
 9e7:   89 f6                   mov    %esi,%esi
 9e9:   8d bc 27 00 00 00 00    lea    0x0(%edi),%edi


Quite nice :)
-- 
Matt




More information about the ecl-devel mailing list