| 1 |
/* { dg-add-options vect_early_break } */ |
| 2 |
/* { dg-additional-options "-funswitch-loops" } */ |
| 3 |
|
| 4 |
#include "tree-vect.h" |
| 5 |
|
| 6 |
typedef int type; |
| 7 |
typedef type Vec2[2]; |
| 8 |
|
| 9 |
struct BytesVec { |
| 10 |
type d[100]; |
| 11 |
}; |
| 12 |
|
| 13 |
__attribute__((noipa)) struct BytesVec |
| 14 |
buildVertexBufferData(const Vec2 *origVertices, bool needsZW, |
| 15 |
unsigned paddingSize, unsigned long t) { |
| 16 |
const unsigned vertexCount = t; |
| 17 |
struct BytesVec data = (struct BytesVec){.d = {0}}; |
| 18 |
type *nextVertexPtr = data.d; |
| 19 |
|
| 20 |
for (unsigned vertexIdx = 0u; vertexIdx < vertexCount; ++vertexIdx) { |
| 21 |
|
| 22 |
if (vertexIdx > t) |
| 23 |
__builtin_trap(); |
| 24 |
__builtin_memcpy(nextVertexPtr, &origVertices[vertexIdx], |
| 25 |
2 * sizeof(type)); |
| 26 |
nextVertexPtr += 2; |
| 27 |
|
| 28 |
if (needsZW) { |
| 29 |
nextVertexPtr += 2; |
| 30 |
} |
| 31 |
|
| 32 |
nextVertexPtr += paddingSize; |
| 33 |
} |
| 34 |
|
| 35 |
return data; |
| 36 |
} |
| 37 |
Vec2 origVertices[] = { |
| 38 |
{0, 1}, {2, 3}, {4, 5}, {6, 7}, |
| 39 |
{8, 9}, {10, 11}, {12, 13}, {14, 15}, |
| 40 |
{16, 17}, {18, 19}, {20, 21}, {22, 23}, |
| 41 |
{24, 25}, {26, 27}, {27, 28}, {29, 30}, |
| 42 |
}; |
| 43 |
|
| 44 |
int main() |
| 45 |
{ |
| 46 |
check_vect (); |
| 47 |
struct BytesVec vec |
| 48 |
= buildVertexBufferData(origVertices, false, 0, |
| 49 |
sizeof(origVertices) / sizeof(origVertices[0])); |
| 50 |
|
| 51 |
int errors = 0; |
| 52 |
for (unsigned i = 0; i < 100; i++) { |
| 53 |
if (i / 2 < sizeof(origVertices) / sizeof(origVertices[0])) { |
| 54 |
int ii = i; |
| 55 |
int e = origVertices[ii / 2][ii % 2]; |
| 56 |
if (vec.d[i] != e) |
| 57 |
errors++; |
| 58 |
} else { |
| 59 |
if (vec.d[i] != 0) |
| 60 |
errors++; |
| 61 |
} |
| 62 |
} |
| 63 |
if (errors) |
| 64 |
__builtin_abort(); |
| 65 |
return 0; |
| 66 |
} |