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

--- Comment #10 from Tamar Christina <tnfchris 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.
> 

But you can't. the misalignment is dynamic, not static. You statically can't
know.

i.e.

  char p[] = {
      0x2f, 0x2a, 0xa,  0x20, 0x20, 0x20, 0x62, 0x75, 0x67, 0x33, 0x33, 0x37,
      0x39, 0x37, 0x32, 0x33, 0x2e, 0x63, 0xa,  0x2a, 0x2f, 0xa,  0xa,  0x23,
      0x69, 0x6e, 0x63,
  };

  if (foo (&p[2], sizeof(p)-2))
    return 0;

  return 1;

foo doesn't know that you misaligned p. when vectorizing p all you know if an
unknown alignment.

Reply via email to