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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|middle-end                  |fortran
     Ever confirmed|0                           |1
         Resolution|INVALID                     |---
             Status|RESOLVED                    |REOPENED
   Last reconfirmed|                            |2025-10-22

--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> ---
For gfortran.dg/deferred_character_23.f90, with -O0, middle-end passes

(gdb) call debug (max_size_exp)
(const_int 32 [0x20])
(gdb) call debug (min_size_exp)
(const_int 32 [0x20])
(gdb) call debug (count_exp)
(subreg:SI (reg:DI 118 [ _21 ]) 0)

to movmem expander from

  .strings_267 = 32;
  ...
  ...
  <bb 14> :
  _288 = .strings_267;
  _14 = S.10_214 + _286;
  _15 = _283 + _14;
  _16 = strings.span;
  _17 = _15 * _16;
  _18 = (sizetype) _17;
  _289 = _282 + _18;
  _290 = A.8[S.10_214];
  _291 = _288 + -32;
  if (_288 > 0)
    goto <bb 15>; [INV]
  else
    goto <bb 18>; [INV]

  <bb 15> :
  if (_288 > 32)
    goto <bb 16>; [INV]
  else
    goto <bb 17>; [INV]

  <bb 16> :
  __builtin_memmove (_289, _290, 32);
  _19 = (unsigned long) _291;
  _20 = _289 + 32;
  __builtin_memset (_20, 32, _19);
  goto <bb 18>; [INV]

  <bb 17> :
  _21 = (unsigned long) _288;
  __builtin_memmove (_289, _290, _21);

  <bb 18> :
  S.10_295 = S.10_214 + 1;
  goto <bb 13>; [INV]
  ...
  _27 = _gfortran_string_len_trim (.strings_267, _26);

At run-time, 2 is passed to memmove, instead of 32.  Does Fortran frontend let
the middle-end know that _gfortran_string_len_trim may change .strings_267?

Reply via email to