From 1493634920005070de5611ce90c868efde5c6071 Mon Sep 17 00:00:00 2001
From: Ryan Oldenburg <ryan@guzba.com>
Date: Wed, 15 Jun 2022 14:26:47 -0500
Subject: [PATCH] faster

---
 src/pixie/internal.nim | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/pixie/internal.nim b/src/pixie/internal.nim
index 9fda619..095147d 100644
--- a/src/pixie/internal.nim
+++ b/src/pixie/internal.nim
@@ -65,11 +65,15 @@ proc fillUnsafe*(
   else:
     var i = start
     when defined(amd64) and allowSimd:
+      # Align to 16 bytes
+      while (cast[uint](data[i].addr) and 15) != 0:
+        data[i] = rgbx
+        inc i
       # When supported, SIMD fill until we run out of room
       let colorVec = mm_set1_epi32(cast[int32](rgbx))
       for _ in 0 ..< len div 8:
-        mm_storeu_si128(data[i + 0].addr, colorVec)
-        mm_storeu_si128(data[i + 4].addr, colorVec)
+        mm_store_si128(data[i + 0].addr, colorVec)
+        mm_store_si128(data[i + 4].addr, colorVec)
         i += 8
     else:
       when sizeof(int) == 8: