How to tell GCC there is no pointer aliasing for loop auto-vectorization? (Restrict doesn't work)

空扰寡人 提交于 2019-12-11 12:14:10

问题


I am having problems getting GCC to vectorize this loop:

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]; 

    }

These variables come from two matrices (scoreMatrix and shiftMatrix, which are declared aligned and are guaranteed to have each "row" start aligned), as well as an 8-bit array (fillRow). GCC keeps telling me:

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

Where line 600 is the loop in question. I don't know how to make it any more explicit that there is no aliasing going on. Previously I left out the diagShift and diagScore lines and just had the loop index, for instance, prevRow[j-1] instead of "diagShift[j]" -- exact same result. What can I do?

来源:https://stackoverflow.com/questions/31575698/how-to-tell-gcc-there-is-no-pointer-aliasing-for-loop-auto-vectorization-restr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!