summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-03-17 09:21:00 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2012-03-17 09:25:30 +0000
commite31d9dacafe060dc86de801114b475fdd0142eb6 (patch)
tree6671818aa224f635b09bb64ef146e6669434a429
parent2b4e11923d9f683f43acf8053bcec1701df25c1f (diff)
sna/traps: Align indices for unrolled memset in row_inplace()
The compiler presumes that the uint64_t write is naturally aligned and so may emit code that crashes with an unaligned moved. To workaround this, make sure the write is so aligned. References: https://bugs.freedesktop.org/show_bug.cgi?id=47418 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/sna_trapezoids.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/sna/sna_trapezoids.c b/src/sna/sna_trapezoids.c
index 31a661e5..3a93450c 100644
--- a/src/sna/sna_trapezoids.c
+++ b/src/sna/sna_trapezoids.c
@@ -1499,6 +1499,21 @@ inplace_row(struct active_list *active, uint8_t *row, int width)
else
memset(row+lix, 0xff, rix);
#else
+ if (lix & 1 && rix) {
+ row[lix] = 0xff;
+ lix++;
+ rix--;
+ }
+ if (lix & 2 && rix >= 2) {
+ *(uint16_t *)(row+lix) = 0xffff;
+ lix += 2;
+ rix -= 2;
+ }
+ if (lix & 4 && rix >= 4) {
+ *(uint32_t *)(row+lix) = 0xffffffff;
+ lix += 4;
+ rix -= 4;
+ }
while (rix >= 8) {
*(uint64_t *)(row+lix) = 0xffffffffffffffff;
lix += 8;