blob: c895e94021d203909787532f829ebfa65d70ed19 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
/* { dg-additional-options "-mavx2" { target avx2_runtime } } */
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include "tree-vect.h"
#define B 0
#define G 1
#define R 2
#define A 3
int red = 153;
int green = 66;
int blue = 187;
int alpha = 255;
static void __attribute__((noipa))
sub_left_prediction_bgr32(uint8_t *restrict dst, uint8_t *restrict src, int w)
{
for (int i = 0; i < 8; i++) {
int rt = src[i * 4 + R];
int gt = src[i * 4 + G];
int bt = src[i * 4 + B];
int at = src[i * 4 + A];
dst[i * 4 + R] = rt - red;
dst[i * 4 + G] = gt - green;
dst[i * 4 + B] = bt - blue;
dst[i * 4 + A] = at - alpha;
red = rt;
green = gt;
blue = bt;
alpha = at;
}
}
int main()
{
check_vect ();
uint8_t *dst = calloc(36, sizeof(uint8_t));
uint8_t *src = calloc(36, sizeof(uint8_t));
src[R] = 160;
src[G] = 73;
src[B] = 194;
src[A] = 255;
sub_left_prediction_bgr32(dst, src, 33);
if (dst[R] != 7 || dst[B] != 7 || dst[A] != 0)
__builtin_abort();
}
|