[ros-kernel] Little speedup (Nope)

Waldo Alvarez Cañizares wac at lab.matcom.uh.cu
Mon Mar 29 15:19:08 CEST 2004


 
Hi Thomas:
 
That is not a speed-up. What you did there was instead a little obfuscation. You have to get a very dumb compiler to generate a division for a power of two. BTW GCC sometimes generates some mixture of shifts, additions and /or substractions equivalent to multiplications or divisions so most of the times GCC is cleaver enough (jeje sometimes better than me :) ) to let that kind of optimization job to the compiler. So... there is not point in doing that. If I'd were you I would revert the changes.
 
Best Regards
Waldo Alvarez

________________________________

From: ros-diffs-bounces at reactos.com on behalf of weiden at osexperts.com
Sent: Fri 3/26/2004 6:48 PM
To: ros-diffs at reactos.com
Subject: [ros-diffs] [CVS reactos] little speed-up


Commit in reactos/subsys/win32k/dib on MAIN	
dib16bpp.c	 +4	 -4	 1.19 <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys/win32k/dib/dib16bpp.c?rev=1.19&content-type=text/x-cvsweb-markup>  -> <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys/win32k/dib/dib16bpp.c.diff?r1=text&tr1=1.19&r2=text&tr2=1.20&f=h>  1.20 <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys/win32k/dib/dib16bpp.c?rev=1.20&content-type=text/x-cvsweb-markup> 	
dib32bpp.c	 +5	 -5	 1.12 <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys/win32k/dib/dib32bpp.c?rev=1.12&content-type=text/x-cvsweb-markup>  -> <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys/win32k/dib/dib32bpp.c.diff?r1=text&tr1=1.12&r2=text&tr2=1.13&f=h>  1.13 <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys/win32k/dib/dib32bpp.c?rev=1.13&content-type=text/x-cvsweb-markup> 	
dib8bpp.c	 +4	 -4	 1.14 <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys/win32k/dib/dib8bpp.c?rev=1.14&content-type=text/x-cvsweb-markup>  -> <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys/win32k/dib/dib8bpp.c.diff?r1=text&tr1=1.14&r2=text&tr2=1.15&f=h>  1.15 <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys/win32k/dib/dib8bpp.c?rev=1.15&content-type=text/x-cvsweb-markup> 	
	+13	 -13	 	
3 modified files

little speed-up

________________________________

reactos <http://cvs.reactos.com/cgi-bin/cvsweb/reactos> /subsys <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys> /win32k <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys/win32k> /dib <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys/win32k/dib> 

dib16bpp.c 1.19 <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys/win32k/dib/dib16bpp.c?rev=1.19&content-type=text/x-cvsweb-markup>  -> <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys/win32k/dib/dib16bpp.c.diff?r1=text&tr1=1.19&r2=text&tr2=1.20&f=h>  1.20 <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys/win32k/dib/dib16bpp.c?rev=1.20&content-type=text/x-cvsweb-markup> 
diff -u -r1.19 -r1.20
--- dib16bpp.c	19 Feb 2004 09:31:30 -0000	1.19
+++ dib16bpp.c	26 Mar 2004 23:48:47 -0000	1.20
@@ -16,7 +16,7 @@

  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */

-/* $Id: dib16bpp.c,v 1.19 2004/02/19 09:31:30 fireball Exp $ */

+/* $Id: dib16bpp.c,v 1.20 2004/03/26 23:48:47 weiden Exp $ */

 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <stdlib.h>

@@ -393,7 +393,7 @@

   int NumPixels = TgtWidth;
   int IntPart = SrcWidth / TgtWidth;
   int FractPart = SrcWidth % TgtWidth;

-  int Mid = TgtWidth / 2;

+  int Mid = TgtWidth >> 1;

   int E = 0;
   int skip;
   PIXEL p;

@@ -422,9 +422,9 @@

                   int TgtWidth, int TgtHeight, int srcPitch, int dstPitch)
 {
   int NumPixels = TgtHeight;

-  int IntPart = ((SrcHeight / TgtHeight) * srcPitch) / 2; //(SrcHeight / TgtHeight) * SrcWidth;

+  int IntPart = ((SrcHeight / TgtHeight) * srcPitch) >> 1; //(SrcHeight / TgtHeight) * SrcWidth;

   int FractPart = SrcHeight % TgtHeight;

-  int Mid = TgtHeight / 2;

+  int Mid = TgtHeight >> 1;

   int E = 0;
   int skip;
   PIXEL *ScanLine, *ScanLineAhead;

________________________________

reactos <http://cvs.reactos.com/cgi-bin/cvsweb/reactos> /subsys <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys> /win32k <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys/win32k> /dib <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys/win32k/dib> 

dib32bpp.c 1.12 <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys/win32k/dib/dib32bpp.c?rev=1.12&content-type=text/x-cvsweb-markup>  -> <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys/win32k/dib/dib32bpp.c.diff?r1=text&tr1=1.12&r2=text&tr2=1.13&f=h>  1.13 <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys/win32k/dib/dib32bpp.c?rev=1.13&content-type=text/x-cvsweb-markup> 
diff -u -r1.12 -r1.13
--- dib32bpp.c	21 Feb 2004 09:06:25 -0000	1.12
+++ dib32bpp.c	26 Mar 2004 23:48:47 -0000	1.13
@@ -16,7 +16,7 @@

  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */

-/* $Id: dib32bpp.c,v 1.12 2004/02/21 09:06:25 navaraf Exp $ */

+/* $Id: dib32bpp.c,v 1.13 2004/03/26 23:48:47 weiden Exp $ */

 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <stdlib.h>

@@ -64,7 +64,7 @@

 {
   PBYTE byteaddr = SurfObj->pvScan0 + y1 * SurfObj->lDelta;
   PDWORD addr = (PDWORD)byteaddr + x;

-  LONG lDelta = SurfObj->lDelta / sizeof(DWORD);

+  LONG lDelta = SurfObj->lDelta >> 2; /* >> 2 == / sizeof(DWORD) */

 
   byteaddr = (PBYTE)addr;
   while(y1++ < y2) {

@@ -309,7 +309,7 @@

   int NumPixels = TgtWidth;
   int IntPart = SrcWidth / TgtWidth;
   int FractPart = SrcWidth % TgtWidth;

-  int Mid = TgtWidth / 2;

+  int Mid = TgtWidth >> 1;

   int E = 0;
   int skip;
   PIXEL p;

@@ -338,9 +338,9 @@

                   int TgtWidth, int TgtHeight, int srcPitch, int dstPitch)
 {
   int NumPixels = TgtHeight;

-  int IntPart = ((SrcHeight / TgtHeight) * srcPitch) / 2; //(SrcHeight / TgtHeight) * SrcWidth;

+  int IntPart = ((SrcHeight / TgtHeight) * srcPitch) >> 1; //(SrcHeight / TgtHeight) * SrcWidth;

   int FractPart = SrcHeight % TgtHeight;

-  int Mid = TgtHeight / 2;

+  int Mid = TgtHeight >> 1;

   int E = 0;
   int skip;
   PIXEL *ScanLine, *ScanLineAhead;

________________________________

reactos <http://cvs.reactos.com/cgi-bin/cvsweb/reactos> /subsys <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys> /win32k <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys/win32k> /dib <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys/win32k/dib> 

dib8bpp.c 1.14 <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys/win32k/dib/dib8bpp.c?rev=1.14&content-type=text/x-cvsweb-markup>  -> <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys/win32k/dib/dib8bpp.c.diff?r1=text&tr1=1.14&r2=text&tr2=1.15&f=h>  1.15 <http://cvs.reactos.com/cgi-bin/cvsweb/reactos/subsys/win32k/dib/dib8bpp.c?rev=1.15&content-type=text/x-cvsweb-markup> 
diff -u -r1.14 -r1.15
--- dib8bpp.c	21 Feb 2004 09:06:25 -0000	1.14
+++ dib8bpp.c	26 Mar 2004 23:48:47 -0000	1.15
@@ -16,7 +16,7 @@

  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */

-/* $Id: dib8bpp.c,v 1.14 2004/02/21 09:06:25 navaraf Exp $ */

+/* $Id: dib8bpp.c,v 1.15 2004/03/26 23:48:47 weiden Exp $ */

 #undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <stdlib.h>

@@ -364,7 +364,7 @@

   int NumPixels = TgtWidth;
   int IntPart = SrcWidth / TgtWidth;
   int FractPart = SrcWidth % TgtWidth;

-  int Mid = TgtWidth / 2;

+  int Mid = TgtWidth >> 1;

   int E = 0;
   int skip;
   PIXEL p;

@@ -393,9 +393,9 @@

                   int TgtWidth, int TgtHeight, int srcPitch, int dstPitch)
 {
   int NumPixels = TgtHeight;

-  int IntPart = ((SrcHeight / TgtHeight) * srcPitch) / 2; //(SrcHeight / TgtHeight) * SrcWidth;

+  int IntPart = ((SrcHeight / TgtHeight) * srcPitch) >> 1; //(SrcHeight / TgtHeight) * SrcWidth;

   int FractPart = SrcHeight % TgtHeight;

-  int Mid = TgtHeight / 2;

+  int Mid = TgtHeight >> 1;

   int E = 0;
   int skip;
   PIXEL *ScanLine, *ScanLineAhead;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 13662 bytes
Desc: not available
Url : http://reactos.com:8080/pipermail/ros-kernel/attachments/20040329/4c05d8ec/attachment-0001.bin


More information about the Ros-kernel mailing list