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

--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to rguent...@suse.de from comment #9)
> On Wed, 26 Feb 2025, tnfchris at gcc dot gnu.org wrote:
> 
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119016
> > 
> > --- Comment #8 from Tamar Christina <tnfchris at gcc dot gnu.org> ---
> > (In reply to rguent...@suse.de from comment #7)
> > > On Wed, 26 Feb 2025, tnfchris at gcc dot gnu.org wrote:
> > > 
> > > > Because of the scalar code doing DI mode loads, and the misalignment 
> > > > being
> > > > HImode,  I don't think the alignment can be reached by peeling.
> > > > 
> > > > i.e. I don't think you can reach target alignment, and unless I'm 
> > > > missing
> > > > something, get_misalign_in_elems does not have a failure mode for when 
> > > > target
> > > > alignment can't be reached?
> > > 
> > > get_misalign_in_elems of course returns garbage when the access isn't
> > > element aligned - we're not supposed to compute it in this case.
> > 
> > Indeed, so it looks like we need an additional check in the pre-header that
> > checks if the address's misalignment can be corrected to target alignment. 
> 
> No, we should not attempt to peel such DR instead - IIRC
> we check alignment_reachable for this, so I'm not sure why it doens't
> work.

So the issue is that

chunk_18 = MEM[(const uintptr_t *)buf_34];

performs an aligned scalar access.

    uintptr_t chunk = *(const uintptr_t *)buf;

is UB iff buf isn't aligned according to uintptr_t requirement.

Reply via email to