https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124580
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |alias
Summary|RISCV: Redundant memory |Redundant memory loads in
|loads in x264_pixel_sad |x264_pixel_sad function
|function |
Component|target |middle-end
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
> Since there are no dependencies between the three SAD calculation
That is NOT true at least according to the aliasing rules of C here.
scores and fenc could overlap and still be valid because the character types
(unsigned char, signed char and char) can be used to access any types that was
store beforehand.
Marking fenc with an restrict qualifier does fix the issue even (`uint8_t *
__restrict fenc`).
Or doing this:
```
int scores0 = x264_pixel_sad_8x8( fenc, FENC_STRIDE, pix0, i_stride );\
int scores1 = x264_pixel_sad_8x8( fenc, FENC_STRIDE, pix1, i_stride );\
int scores2 = x264_pixel_sad_8x8( fenc, FENC_STRIDE, pix2, i_stride );\
scores[0] = scores0;
scores[1] = scores1;
scores[2] = scores2;
```
Now we could make a clone of this function for the case where all argument
don't alias but I am not sure that will always be profitable and how to detect
which arugments don't overlap or how wide the check would be. Note 3 in the
array type in the argument is just a suggestion and the type decays to a
pointer so it is hard to figure how big really.