summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/vect/pr64829.c
blob: 6a9f3d785fd16ec4a668fdb7bcd7f50beeaf6f5d (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
55
56
57
58
59
60
61
62
63
64
65
/* { dg-do compile } */

typedef unsigned char Uint8;
typedef int Sint32;
typedef unsigned int Uint32;

typedef union RMColorDataRef
{
  Uint8* data8;
} RMColorDataRef;

typedef struct RMColorData
{
  Uint32 dataCount;
  RMColorDataRef dataRef;
} RMColorData;

typedef struct RMColorTable
{
  Uint8 dataCompsOut;
  RMColorDataRef dataRef;
} RMColorTable;

int fail ( const RMColorData * pInColor,
	   RMColorData * pOutColor,
	   const RMColorTable * pColorTable )
{
  Uint32 comp;
  Uint8 nCompOut;

  Sint32 result;

  Uint32 interpFrac1, interpFrac2, interpFrac3;
  Sint32 val0, val1, val2, val3;

  Uint8 * pOut;

  const Uint8 * pClutData;
  const Uint8 * pCornerPoint0;

  Uint8 lastOut[((8) > (4) ? (8) : (4))];

  pOut = pOutColor->dataRef.data8;
  pClutData = pColorTable->dataRef.data8;

  nCompOut = pColorTable->dataCompsOut;

  pCornerPoint0 = pClutData;

  for (comp = 0; comp < nCompOut; comp++)
    {
      val0 = *pCornerPoint0++;

      result = val0 << 4;

      result += (val1 - val0) * interpFrac1;
      result += (val2 - val1) * interpFrac2;
      result += (val3 - val2) * interpFrac3;

      *pOut++ = lastOut[comp] = (Uint8)(result >> 4);
    }

  return (0);
}