The mmx memory copy code is not nearly as efficient as memcpy(), which would make draw_edges_mmx much slower than draw_edges_8_c. Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz: before after draw_edges_8_1724_4_mmx: 8700.5 8751.8 ( 0.99x) draw_edges_8_1724_8_mmx: 10441.7 10558.0 ( 0.99x) draw_edges_8_1724_16_mmx: 10660.7 10799.5 ( 0.99x) draw_edges_128_407_4_mmx: 4202.2 4099.3 ( 1.03x) draw_edges_128_407_8_mmx: 4579.0 4511.3 ( 1.02x) draw_edges_128_407_16_mmx: 5479.7 4729.5 ( 1.16x) draw_edges_1080_31_4_mmx: 1546.7 658.0 ( 2.35x) draw_edges_1080_31_8_mmx: 2745.5 1442.5 ( 1.90x) draw_edges_1080_31_16_mmx: 12511.5 4901.0 ( 2.55x) draw_edges_1920_4_4_mmx: 2659.0 705.0 ( 3.77x) draw_edges_1920_4_4_negstride_mmx: 2643.0 729.0 ( 3.63x) draw_edges_1920_4_8_mmx: 7845.0 2819.0 ( 2.78x) draw_edges_1920_4_8_negstride_mmx: 7777.0 2747.3 ( 2.83x) draw_edges_1920_4_16_mmx: 24583.7 6358.3 ( 3.87x) draw_edges_1920_4_16_negstride_mmx: 24589.0 6367.0 ( 3.86x)
Unified · Split
| @@ -102,7 +102,6 @@ static void draw_edges_mmx(uint8_t *buf, int wrap, int width, int height, · 101 unmodified lines | ||
| 102 | 102 | uint8_t *ptr, *last_line; |
| 103 | 103 | int i; |
| 104 | 104 | |
| 105 | − last_line = buf + (height - 1) * wrap; | |
| 106 | 105 | /* left and right */ |
| 107 | 106 | ptr = buf; |
| 108 | 107 | if (w == 8) { |
| @@ -166,46 +165,17 @@ static void draw_edges_mmx(uint8_t *buf, int wrap, int width, int height, · 57 unmodified lines | ||
| 166 | 165 | "r" (ptr + wrap * height)); |
| 167 | 166 | } |
| 168 | 167 | |
| 169 | − /* top and bottom (and hopefully also the corners) */ | |
| 170 | − if (sides & EDGE_TOP) { | |
| 171 | − for (i = 0; i < h; i += 4) { | |
| 172 | − ptr = buf - (i + 1) * wrap - w; | |
| 173 | − __asm__ volatile ( | |
| 174 | − "1: \n\t" | |
| 175 | − "movq (%1, %0), %%mm0 \n\t" | |
| 176 | − "movq %%mm0, (%0) \n\t" | |
| 177 | − "movq %%mm0, (%0, %2) \n\t" | |
| 178 | − "movq %%mm0, (%0, %2, 2) \n\t" | |
| 179 | − "movq %%mm0, (%0, %3) \n\t" | |
| 180 | − "add $8, %0 \n\t" | |
| 181 | − "cmp %4, %0 \n\t" | |
| 182 | − "jb 1b \n\t" | |
| 183 | − : "+r" (ptr) | |
| 184 | − : "r" ((x86_reg) buf - (x86_reg) ptr - w), | |
| 185 | − "r" ((x86_reg) - wrap), "r" ((x86_reg) - wrap * 3), | |
| 186 | − "r" (ptr + width + 2 * w)); | |
| 187 | − } | |
| 188 | − } | |
| 189 | − | |
| 190 | − if (sides & EDGE_BOTTOM) { | |
| 191 | − for (i = 0; i < h; i += 4) { | |
| 192 | − ptr = last_line + (i + 1) * wrap - w; | |
| 193 | − __asm__ volatile ( | |
| 194 | − "1: \n\t" | |
| 195 | − "movq (%1, %0), %%mm0 \n\t" | |
| 196 | − "movq %%mm0, (%0) \n\t" | |
| 197 | − "movq %%mm0, (%0, %2) \n\t" | |
| 198 | − "movq %%mm0, (%0, %2, 2) \n\t" | |
| 199 | − "movq %%mm0, (%0, %3) \n\t" | |
| 200 | − "add $8, %0 \n\t" | |
| 201 | − "cmp %4, %0 \n\t" | |
| 202 | − "jb 1b \n\t" | |
| 203 | − : "+r" (ptr) | |
| 204 | − : "r" ((x86_reg) last_line - (x86_reg) ptr - w), | |
| 205 | − "r" ((x86_reg) wrap), "r" ((x86_reg) wrap * 3), | |
| 206 | − "r" (ptr + width + 2 * w)); | |
| 207 | − } | |
| 208 | − } | |
| 168 | + /* top and bottom + corners */ | |
| 169 | + buf -= w; | |
| 170 | + last_line = buf + (height - 1) * wrap; | |
| 171 | + if (sides & EDGE_TOP) | |
| 172 | + for (i = 0; i < h; i++) | |
| 173 | + // top | |
| 174 | + memcpy(buf - (i + 1) * wrap, buf, width + w + w); | |
| 175 | + if (sides & EDGE_BOTTOM) | |
| 176 | + for (i = 0; i < h; i++) | |
| 177 | + // bottom | |
| 178 | + memcpy(last_line + (i + 1) * wrap, last_line, width + w + w); | |
| 209 | 179 | } |
| 210 | 180 | |
| 211 | 181 | #endif /* HAVE_INLINE_ASM */ |