[Bug fortran/38592] eliminate some string comparisons

2016-10-09 Thread tkoenig at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38592

--- Comment #7 from Thomas Koenig  ---
We still do the comparison, although with memcmp now.

More interesting question is if we could/should do
forward propagation of values in the front end,
or if this is something that the middle-end should,
in principle, do.

[Bug fortran/38592] eliminate some string comparisons

2016-10-07 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38592

kargl at gcc dot gnu.org changed:

   What|Removed |Added

 CC||kargl at gcc dot gnu.org

--- Comment #6 from kargl at gcc dot gnu.org ---
Sometime between 4.8.4 and 4.9.4, the _gfortran_compare_string
has been replaced by a memcmp().

% gfc48 -O3 -fdump-tree-optimized -S -fdump-tree-original a.f90
% grep compare a.s
call_gfortran_compare_string
% gfc49 -O3 -fdump-tree-optimized -S -fdump-tree-original a.f90
% grep compare a.s


With gcc7, the -fdump-tree-original gives

  __builtin_memmove ((void *) , (void *) &"yes"[1]{lb: 1 sz: 1}, 3);
  {
struct __st_parameter_dt dt_parm.0;

dt_parm.0.common.filename = &"a.f90"[1]{lb: 1 sz: 1};
dt_parm.0.common.line = 4;
dt_parm.0.common.flags = 128;
dt_parm.0.common.unit = 6;
_gfortran_st_write (_parm.0);
{
  logical(kind=4) D.3408;

  D.3408 = __builtin_memcmp ((void *) &"yes"[1]{lb: 1 sz: 1},
 (void *) , 3) == 0;
  _gfortran_transfer_logical_write (_parm.0, , 4);
}
_gfortran_st_write_done (_parm.0);

and -fdump-tree-optimized shows

  :
  MEM[(c_char * {ref-all})] = "yes";
  dt_parm.0.common.filename = &"a.f90"[1]{lb: 1 sz: 1};
  dt_parm.0.common.line = 4;
  dt_parm.0.common.flags = 128;
  dt_parm.0.common.unit = 6;
  _gfortran_st_write (_parm.0);
  _1 = __builtin_memcmp_eq (&"yes"[1]{lb: 1 sz: 1}, , 3);
  _2 = _1 == 0;
  D.3408 = _2;
  _gfortran_transfer_logical_write (_parm.0, , 4);
  D.3408 ={v} {CLOBBER};
  _gfortran_st_write_done (_parm.0);
  dt_parm.0 ={v} {CLOBBER};
  a ={v} {CLOBBER};
  return;

I personally think this is non-issue now and the bug can be
closed.

[Bug fortran/38592] eliminate some string comparisons

2009-05-08 Thread fxcoudert at gcc dot gnu dot org


--- Comment #4 from fxcoudert at gcc dot gnu dot org  2009-05-08 09:30 
---
(In reply to comment #3)
 As a matter of curiosity, do other compilers catch this?

Intel does not.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38592



[Bug fortran/38592] eliminate some string comparisons

2009-05-08 Thread burnus at gcc dot gnu dot org


--- Comment #5 from burnus at gcc dot gnu dot org  2009-05-08 11:25 ---
  As a matter of curiosity, do other compilers catch this?
 Intel does not.

Sure? If I look at the assembler of ifort 11.1 with -O3, I only see:
call  __intel_new_proc_init #1.9
call  for_set_reentrancy#1.9
call  for_write_seq_lis #4.3
And if I'm not mistaken, sunf95 also does not have any call anymore.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38592



[Bug fortran/38592] eliminate some string comparisons

2009-02-18 Thread pault at gcc dot gnu dot org


--- Comment #3 from pault at gcc dot gnu dot org  2009-02-19 05:44 ---
Thomas, As a matter of curiosity, do other compilers catch this?

Confirmed

Paul


-- 

pault at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
 Ever Confirmed|0   |1
   Last reconfirmed|-00-00 00:00:00 |2009-02-19 05:44:12
   date||


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38592



[Bug fortran/38592] eliminate some string comparisons

2008-12-27 Thread dfranke at gcc dot gnu dot org


--- Comment #2 from dfranke at gcc dot gnu dot org  2008-12-28 01:28 ---
This is generally the case, not just for/with strings.

I don't think that anything will ever happen in this regard, at least, not on
the frontend side. If (some) intrinsics, including string comparisons, were
inlined, the optimizers could probably do something about it. 


-- 

dfranke at gcc dot gnu dot org changed:

   What|Removed |Added

 CC||dfranke at gcc dot gnu dot
   ||org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38592



[Bug fortran/38592] eliminate some string comparisons

2008-12-21 Thread tkoenig at gcc dot gnu dot org


--- Comment #1 from tkoenig at gcc dot gnu dot org  2008-12-21 12:03 ---
To clarify, we could detect that the variable only ever
has the value of 'yes'.  We already do the right
thing with constants:

$ cat foo-2.f90
program main
  character(len=3), parameter :: a = 'yes'
  print *,'yes' == a
end program main
$ gfortran -fdump-tree-original foo-2.f90
$ grep compare foo-2.f90.003t.original
$ 


-- 

tkoenig at gcc dot gnu dot org changed:

   What|Removed |Added

   Keywords||missed-optimization
   Priority|P3  |P5
Summary|eliminate constant string   |eliminate some string
   |comparisons |comparisons


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38592