https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119325

--- Comment #14 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #13)
> (In reply to Tobias Burnus from comment #12)
> > BTW, I added some diagnostic to the 'if' clause showing:
> > 
> > v64sf_fmod.c:147:109: warning: ‘__from’ (‘v2sf’ {aka ‘__vector(2) float’}):
> > size = 8, align = 64
> > v64sf_fmod.c:147:198: warning: ‘__from’ (‘v2sf’ {aka ‘__vector(2) float’}):
> > size = 8, align = 64
> > v64sf_fmod.c:147:3730: warning: ‘__from’ (‘v4sf’ {aka ‘__vector(4) float’}):
> > size = 16, align = 128
> > v64sf_fmod.c:147:3819: warning: ‘__from’ (‘v4sf’ {aka ‘__vector(4) float’}):
> > size = 16, align = 128
> > v64sf_fmod.c:147:7351: warning: ‘__from’ (‘v8sf’ {aka ‘__vector(8) float’}):
> > size = 32, align = 256
> > v64sf_fmod.c:147:7440: warning: ‘__from’ (‘v8sf’ {aka ‘__vector(8) float’}):
> > size = 32, align = 256
> > v64sf_fmod.c:147:10976: warning: ‘__from’ (‘v16sf’ {aka ‘__vector(16)
> > float’}): size = 64, align = 512
> > v64sf_fmod.c:147:11065: warning: ‘__from’ (‘v16sf’ {aka ‘__vector(16)
> > float’}): size = 64, align = 512
> > v64sf_fmod.c:147:14627: warning: ‘__from’ (‘v32sf’ {aka ‘__vector(32)
> > float’}): size = 128, align = 1024
> > v64sf_fmod.c:147:14716: warning: ‘__from’ (‘v32sf’ {aka ‘__vector(32)
> > float’}): size = 128, align = 1024
> >   147 | DEF_VARIANTS2 (fmodf, sf, sf)
> > 
> > That's for the expansion of RESIZE_VECTOR:
> > 
> > amdgcn_veclib.h:89:3: warning: ‘__from’ (‘v2sf’ {aka ‘__vector(2) float’}):
> > size = 8, align = 64
> >    89 |   *((to_t *) &__from); \
> >       |   ^~~~~~~~~~~~~~~~~~~
> > 
> > i.e.
> > 
> >   84 /* Cast between vectors with a different number of elements.  */
> >   85 
> >   86 #define RESIZE_VECTOR(to_t, from) \
> >   87 ({ \
> >   88   __auto_type __from = (from); \
> >   89   *((to_t *) &__from); \
> >   90 })
> 
> The if-condition should only trigger if the access (which might be a
> sub-access)
> is completely out of bounds of the target.  Say, if for weird reason
> the above has to_t bigger than __from, and thus if we'd for some reason
> split the access have the "upper part" be outside of __from.
> 
> What's 'offset' in these cases?

So indeed I see for example

MEM[(v64sf *)&__from]

and __from is v2sf.  That's UB.

You need to do this differently.

Reply via email to