我在让 GCC 对这个循环进行矢量化时遇到问题:
register int_fast8_t __attribute__ ((aligned)) * restrict fillRow = __builtin_assume_aligned(rowMaps + query[i]*rowLen,8);
register int __attribute__ ((aligned (16))) *restrict curRow = __builtin_assume_aligned(scoreMatrix + i*rowLen,16),
__attribute__ ((aligned (16))) *restrict prevRow = __builtin_assume_aligned(curRow - rowLen,16);
register unsigned __attribute__ ((aligned (16))) *restrict shiftCur = __builtin_assume_aligned(shiftMatrix + i*rowLen,16),
__attribute__ ((aligned (16))) *restrict shiftPrev = __builtin_assume_aligned(shiftCur - rowLen,16);
unsigned j;
unsigned *restrict diagShift = shiftPrev - 1;
int *restrict diagScore = prevRow - 1;
for (j=1; j < rs; ++j) {
curRow[j] = diagScore[j] + fillRow[j];
shiftCur[j] = diagShift[j];
}
这些变量来自两个矩阵(scoreMatrix 和 shiftMatrix,它们被声明为对齐并保证每个“行”开始对齐),以及一个 8 位数组 (fillRow)。GCC 不断告诉我:
prog.c:600:4: note: === vect_analyze_data_ref_dependences ===
prog.c:600:4: note: versioning for alias required: can't determine dependence between *_90 and *_89
prog.c:600:4: note: mark for run-time aliasing test between *_90 and *_89
prog.c:600:4: note: versioning for alias required: can't determine dependence between *_98 and *_97
prog.c:600:4: note: mark for run-time aliasing test between *_98 and *_97
其中第 600 行是有问题的循环。我不知道如何更明确地表明没有别名发生。以前我省略了 diagShift 和 diagScore 行,只使用了循环索引,例如 prevRow[j-1] 而不是“diagShift[j]”——结果完全相同。我能做些什么?