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

Michail <m.kashkarov at partner dot samsung.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |m.kashkarov at partner dot 
samsung
                   |                            |.com

--- Comment #16 from Michail <m.kashkarov at partner dot samsung.com> ---
> Agreed, but, I'm just wondering why it has diffrent behavior according by
> GCC version with -Os. (It should be same result if the choice is made by
> their instructions and costs)

I think that for this example GCC 7 generates memset() call after changes in
tree-ssa-dse
https://gcc.gnu.org/viewcvs/gcc?limit_changes=0&view=revision&revision=244442
(tuning is the same)

for reduced test:
$ cat memset_test_reduced.c
long long func1( long long *pl) 
{
  long  long  r = 0;
  for(int i=0; i<2; i++)
    r += ( long long ) pl[i];
  return r;
}

long long test_func(void) 
{
  long long x[2] = {0};
  x[0] = 3;
  x[1] = 4;
  return func1(x);
}

compiled with:
gcc -S memset_test_reduced.c -g -mabi=aapcs -fno-function-sections -Wall
-mfloat-abi=soft -Os -mtune=cortex-a9 -fdump-tree-all

Difference between GIMPLE produced by gcc-6.4.1 and gcc-7.2.1 is that gcc-7
optimized out "x = {};" in first DSE pass:

diff -u 6.4.1/memset_test_reduced.c.210t.optimized 
7.2.1/memset_test_reduced.c.227t.optimized
...
test_func ()
 {
   long long int x[2];
-  long long int _5;
+  long long int _4;

-  <bb 2>:
==============
-  x = {};
==============
+  <bb 2> [100.00%]:
   x[0] = 3;
   x[1] = 4;
-  _5 = func1 (&x);
+  _4 = func1 (&x);
   x ={v} {CLOBBER};
-  return _5;
+  return _4;
}

Gcc-6 keeps it and transforms in memset() (according to tune options?) after
all.

Reply via email to