[Pixman] [PATCH v2] mmx: convert while (w) to if (w) when possible

Matt Turner mattst88 at gmail.com
Fri Sep 23 11:12:24 PDT 2011


gcc isn't able to see that w is no greater than 1, so it generates
unnecessary loop instructions with while (w).

Signed-off-by: Matt Turner <mattst88 at gmail.com>
---
v2: removed w--, dst++, src++. Suggested by Taekyun Kim.

 pixman/pixman-mmx.c |   29 +++++------------------------
 1 files changed, 5 insertions(+), 24 deletions(-)

diff --git a/pixman/pixman-mmx.c b/pixman/pixman-mmx.c
index f835a14..c044593 100644
--- a/pixman/pixman-mmx.c
+++ b/pixman/pixman-mmx.c
@@ -1142,12 +1142,9 @@ mmx_composite_over_n_8888 (pixman_implementation_t *imp,
 
 	CHECKPOINT ();
 
-	while (w)
+	if (w)
 	{
 	    *dst = store8888 (over (vsrc, vsrca, load8888 (*dst)));
-
-	    w--;
-	    dst++;
 	}
     }
 
@@ -1383,16 +1380,12 @@ mmx_composite_over_8888_n_8888 (pixman_implementation_t *imp,
 	    src += 2;
 	}
 
-	while (w)
+	if (w)
 	{
 	    __m64 s = load8888 (*src);
 	    __m64 d = load8888 (*dst);
 
 	    *dst = store8888 (in_over (s, expand_alpha (s), vmask, d));
-
-	    w--;
-	    dst++;
-	    src++;
 	}
     }
 
@@ -1758,7 +1751,7 @@ mmx_composite_over_n_8_8888 (pixman_implementation_t *imp,
 
 	CHECKPOINT ();
 
-	while (w)
+	if (w)
 	{
 	    uint64_t m = *mask;
 
@@ -1770,10 +1763,6 @@ mmx_composite_over_n_8_8888 (pixman_implementation_t *imp,
 		    vsrc, vsrca, expand_alpha_rev (to_m64 (m)), vdest);
 		*dst = store8888 (vdest);
 	    }
-
-	    w--;
-	    mask++;
-	    dst++;
 	}
     }
 
@@ -2026,7 +2015,7 @@ mmx_composite_src_n_8_8888 (pixman_implementation_t *imp,
 
 	CHECKPOINT ();
 
-	while (w)
+	if (w)
 	{
 	    uint64_t m = *mask;
 
@@ -2041,10 +2030,6 @@ mmx_composite_src_n_8_8888 (pixman_implementation_t *imp,
 	    {
 		*dst = 0;
 	    }
-
-	    w--;
-	    mask++;
-	    dst++;
 	}
     }
 
@@ -2366,16 +2351,12 @@ mmx_composite_over_pixbuf_8888 (pixman_implementation_t *imp,
 	    src += 2;
 	}
 
-	while (w)
+	if (w)
 	{
 	    __m64 s = load8888 (*src);
 	    __m64 d = load8888 (*dst);
 
 	    *dst = store8888 (over_rev_non_pre (s, d));
-
-	    w--;
-	    dst++;
-	    src++;
 	}
     }
 
-- 
1.7.3.4



More information about the Pixman mailing list