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

--- Comment #11 from Tamar Christina <tnfchris at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #10)
> (In reply to Tamar Christina from comment #8)
> > C testcase
> > 
> > typedef struct {
> >     int _M_current;
> > } __normal_iterator;
> > 
> > typedef struct {
> >     char _M_elems[5];
> > } array_5;
> > 
> > __normal_iterator __trans_tmp_1 = {0};
> > 
> > array_5 copySourceIntoTarget() {
> >     array_5 target;
> >     char* target_it = target._M_elems;
> > 
> >     while (__trans_tmp_1._M_current != 0) {
> >         *target_it = 0;
> >         __trans_tmp_1._M_current++;
> >         target_it++;
> >     }
> > 
> >     return target;
> > }
> > 
> > compiled with -mcpu=neoverse-n2 -O1 -ftree-loop-vectorize
> > 
> > The cost model for Neoverse-N2 is needed to get it to generate an Adv.SIMD
> > main loop and an SVE trailing loop.
> 
> So the issue seems to be that DSE sees the .MASK_STORE after the epilog
> is dead because it is to &target + _55 + POLY_INT_CST[16, 16].  Given
> pointers may not "advance" to before an object we get an ao_ref with base
> 
> &target + _55
> 
> and offset = POLY_INT_CST[16, 16]
> 
> that is always out of char _M_elems[5].
> 
> So, iff that pointer increment by _55 is say for alignment peeling via mask
> with
> a negative bias that pointer arithmetic invokes UB and has to be done
> in uintptr_t.

It's a POINTER_PLUS though, so offset is a ssize_type so should be ok no?

that said, that store isn't the problem, that store is indeed dead.

The store that's still alive is

  vectp_target.14_54 = &targetD.4595 + _55;
  max_mask_63 = .WHILE_ULT (0, bnd.12_51, { 0, ... });
  # .MEM_48 = VDEF <.MEM_31>
  # USE = anything 
  # CLB = anything 
  .MASK_STORE (vectp_target.14_54, 8B, max_mask_63, { 0, ... });

this is storing to &targetD.4595 + _55 and _55 is a PHI <niters, 0>;

so it's a ref with targetD.4595 and offset 0.

So that's within _M_elems[5].

The versioning if on VF here, so if the main loop is skipped the epilogue does
all the work.

Still working through why that ref isn't seen as alive as

  # .MEM_17 = PHI <.MEM_12(10), .MEM_5(D)(2)>
  # .MEM_6 = VDEF <.MEM_17>
  D.4601 = targetD.4595;
  # .MEM_7 = VDEF <.MEM_6>
  targetD.4595 ={v} {CLOBBER(eos)};
  # VUSE <.MEM_7>
  return D.4601;

keeps it alive.

Reply via email to