AZTEC: workaround MSVC optimizer deciding not to emit code for

inner top/right/bottom/left loops of `az_populate_map()` by
  jiggling them around a bit, ticket #317, props Andre Maute
frontend/tests: clean up any directories created in `test_input()`,
  ticket #316, props Andre Maute
This commit is contained in:
gitlost 2024-05-27 03:06:27 +01:00
parent c8bb299908
commit 3960dfdbfc
2 changed files with 31 additions and 27 deletions

View file

@ -716,7 +716,7 @@ static int az_avoidReferenceGrid(int output) {
/* Calculate the position of the bits in the grid (non-compact) */ /* Calculate the position of the bits in the grid (non-compact) */
static void az_populate_map(short AztecMap[], const int layers) { static void az_populate_map(short AztecMap[], const int layers) {
int layer, n, i; int layer;
int x, y; int x, y;
const int offset = AztecOffset[layers - 1]; const int offset = AztecOffset[layers - 1];
const int endoffset = 151 - offset; const int endoffset = 151 - offset;
@ -725,53 +725,50 @@ static void az_populate_map(short AztecMap[], const int layers) {
const int start = (112 * layer) + (16 * layer * layer) + 2; const int start = (112 * layer) + (16 * layer * layer) + 2;
const int length = 28 + (layer * 4) + (layer + 1) * 4; const int length = 28 + (layer * 4) + (layer + 1) * 4;
int av0, av1; int av0, av1;
int n = start, end;
/* Top */ /* Top */
i = 0;
x = 64 - (layer * 2); x = 64 - (layer * 2);
y = 63 - (layer * 2); y = 63 - (layer * 2);
av0 = az_avoidReferenceGrid(y) * 151; av0 = az_avoidReferenceGrid(y) * 151;
av1 = az_avoidReferenceGrid(y - 1) * 151; av1 = az_avoidReferenceGrid(y - 1) * 151;
for (n = start; n < (start + length); n += 2) { end = start + length;
int avxi = az_avoidReferenceGrid(x + i); while (n < end) {
AztecMap[av0 + avxi] = n; const int avxi = az_avoidReferenceGrid(x++);
AztecMap[av1 + avxi] = n + 1; AztecMap[av0 + avxi] = n++;
i++; AztecMap[av1 + avxi] = n++;
} }
/* Right */ /* Right */
i = 0;
x = 78 + (layer * 2); x = 78 + (layer * 2);
y = 64 - (layer * 2); y = 64 - (layer * 2);
av0 = az_avoidReferenceGrid(x); av0 = az_avoidReferenceGrid(x);
av1 = az_avoidReferenceGrid(x + 1); av1 = az_avoidReferenceGrid(x + 1);
for (n = start + length; n < (start + (length * 2)); n += 2) { end += length;
int avyi = az_avoidReferenceGrid(y + i) * 151; while (n < end) {
AztecMap[avyi + av0] = n; const int avyi = az_avoidReferenceGrid(y++) * 151;
AztecMap[avyi + av1] = n + 1; AztecMap[avyi + av0] = n++;
i++; AztecMap[avyi + av1] = n++;
} }
/* Bottom */ /* Bottom */
i = 0;
x = 77 + (layer * 2); x = 77 + (layer * 2);
y = 78 + (layer * 2); y = 78 + (layer * 2);
av0 = az_avoidReferenceGrid(y) * 151; av0 = az_avoidReferenceGrid(y) * 151;
av1 = az_avoidReferenceGrid(y + 1) * 151; av1 = az_avoidReferenceGrid(y + 1) * 151;
for (n = start + (length * 2); n < (start + (length * 3)); n += 2) { end += length;
int avxi = az_avoidReferenceGrid(x - i); while (n < end) {
AztecMap[av0 + avxi] = n; const int avxi = az_avoidReferenceGrid(x--);
AztecMap[av1 + avxi] = n + 1; AztecMap[av0 + avxi] = n++;
i++; AztecMap[av1 + avxi] = n++;
} }
/* Left */ /* Left */
i = 0;
x = 63 - (layer * 2); x = 63 - (layer * 2);
y = 77 + (layer * 2); y = 77 + (layer * 2);
av0 = az_avoidReferenceGrid(x); av0 = az_avoidReferenceGrid(x);
av1 = az_avoidReferenceGrid(x - 1); av1 = az_avoidReferenceGrid(x - 1);
for (n = start + (length * 3); n < (start + (length * 4)); n += 2) { end += length;
int avyi = az_avoidReferenceGrid(y - i) * 151; while (n < end) {
AztecMap[avyi + av0] = n; const int avyi = az_avoidReferenceGrid(y--) * 151;
AztecMap[avyi + av1] = n + 1; AztecMap[avyi + av0] = n++;
i++; AztecMap[avyi + av1] = n++;
} }
} }

View file

@ -552,6 +552,7 @@ static void test_input(const testCtx *const p_ctx) {
for (i = 0; i < data_size; i++) { for (i = 0; i < data_size; i++) {
int j; int j;
char *slash;
if (testContinue(p_ctx, i)) continue; if (testContinue(p_ctx, i)) continue;
#ifdef _WIN32 #ifdef _WIN32
@ -591,8 +592,14 @@ static void test_input(const testCtx *const p_ctx) {
} }
assert_zero(testUtilRemove(input_filename), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", i, input_filename, errno, strerror(errno)); assert_zero(testUtilRemove(input_filename), "i:%d testUtilRemove(%s) != 0 (%d: %s)\n", i, input_filename, errno, strerror(errno));
if (data[i].batch && data[i].mirror && data[i].outfile && data[i].outfile[0] && strcmp(data[i].outfile, TEST_MIRRORED_DIR_TOO_LONG) != 0) {
assert_zero(testUtilRmDir(data[i].outfile), "i:%d testUtilRmDir(%s) != 0 (%d: %s)\n", i, data[i].outfile, errno, strerror(errno)); /* Remove directory if any */
if (data[i].outfile && (slash = strrchr(data[i].outfile, '/')) != NULL && strcmp(data[i].outfile, TEST_MIRRORED_DIR_TOO_LONG) != 0) {
char dirpath[256];
assert_nonzero((size_t) (slash - data[i].outfile) < sizeof(dirpath), "i: %d output directory too long\n", i);
strncpy(dirpath, data[i].outfile, slash - data[i].outfile);
dirpath[slash - data[i].outfile] = '\0';
assert_zero(testUtilRmDir(dirpath), "i:%d testUtilRmDir(%s) != 0 (%d: %s)\n", i, dirpath, errno, strerror(errno));
} }
} }