[Bug target/81907] memset called when it does not need to be; -mtune=cortex-a9

2017-09-05 Thread dongkyun.s at samsung dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81907

dongkyun.s at samsung dot com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |WORKSFORME

--- Comment #18 from dongkyun.s at samsung dot com ---
Dear Michail,
Your analysis was very helpful. I've also verified that compiler may insert
memset() call or not according by 1) DSE optimization - object size/base and
tune options 2) code generation.

[Bug target/81907] memset called when it does not need to be; -mtune=cortex-a9

2017-08-30 Thread m.kashkarov at partner dot samsung.com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81907

--- Comment #17 from Michail  ---

> I think that for this example GCC 7 generates memset() call after changes in
> tree-ssa-dse

I mean GCC 6 generates memset()

[Bug target/81907] memset called when it does not need to be; -mtune=cortex-a9

2017-08-30 Thread m.kashkarov at partner dot samsung.com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81907

Michail  changed:

   What|Removed |Added

 CC||m.kashkarov at partner dot 
samsung
   ||.com

--- Comment #16 from Michail  ---
> 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=revision=22
(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;

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

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

[Bug target/81907] memset called when it does not need to be; -mtune=cortex-a9

2017-08-22 Thread dongkyun.s at samsung dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81907

--- Comment #15 from dongkyun.s at samsung dot com ---
> There's nothing in the compiler that explicitly says: use memset for these 
> cores and not for others.  The choice will be down to available instructions 
> and their relative costs.

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)

[Bug target/81907] memset called when it does not need to be; -mtune=cortex-a9

2017-08-22 Thread rearnsha at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81907

--- Comment #14 from Richard Earnshaw  ---
(In reply to dongkyun.s from comment #13)
> > Confirmed the call on 6.4.1 but GCC 7 and trunk don't generate the call for 
> > -mcpu=cortex-a9 .
> 
> I also verified memset call is not generated with GCC 7.1 + "-mcpu=cortex-a9
> or -mtune=cortex-a9" or lower.
> 
> It seems interesting that 
> in GCC6,
> - don't generate the memset call for -mcpu=cortex-a12 or higer(e.g,
> cortex-a15, V7 big.LITTLE)
> - always generate the memset call for -mcpu=cortex-a9 or lower(e.g,
> cortex-a7, cotex-a5)
> 
> in GCC7.1
> - always don't generate the memset call (even with V3 Architecture
> Processors. e.g, -mcpu=arm7)

There's nothing in the compiler that explicitly says: use memset for these
cores and not for others.  The choice will be down to available instructions
and their relative costs.

[Bug target/81907] memset called when it does not need to be; -mtune=cortex-a9

2017-08-21 Thread dongkyun.s at samsung dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81907

--- Comment #13 from dongkyun.s at samsung dot com ---
> Confirmed the call on 6.4.1 but GCC 7 and trunk don't generate the call for 
> -mcpu=cortex-a9 .

I also verified memset call is not generated with GCC 7.1 + "-mcpu=cortex-a9 or
-mtune=cortex-a9" or lower.

It seems interesting that 
in GCC6,
- don't generate the memset call for -mcpu=cortex-a12 or higer(e.g, cortex-a15,
V7 big.LITTLE)
- always generate the memset call for -mcpu=cortex-a9 or lower(e.g, cortex-a7,
cotex-a5)

in GCC7.1
- always don't generate the memset call (even with V3 Architecture Processors.
e.g, -mcpu=arm7)

[Bug target/81907] memset called when it does not need to be; -mtune=cortex-a9

2017-08-21 Thread ktkachov at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81907

ktkachov at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-08-21
 CC||ktkachov at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #12 from ktkachov at gcc dot gnu.org ---
Confirmed the call on 6.4.1 but GCC 7 and trunk don't generate the call for
-mcpu=cortex-a9 .
I don't know off the top of my head what change fixed this though.

[Bug target/81907] memset called when it does not need to be; -mtune=cortex-a9

2017-08-21 Thread dongkyun.s at samsung dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81907

--- Comment #11 from dongkyun.s at samsung dot com ---
Dear pins...@gcc.gnu.org,
Thanks for correcting title to "memset called when it does not need to be;
-mtune=cortex-a9" along with the comment :)

[Bug target/81907] memset called when it does not need to be; -mtune=cortex-a9

2017-08-21 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81907

--- Comment #10 from Andrew Pinski  ---
(In reply to dongkyun.s from comment #9)
> I mean -ffreestanding or -fno-freestanding are not included in this
> testcase, but, mtune/ mcpu option.
Yes but your summary was saying memset was missing which is not correct and
would cause this bug report to be invalid.  But in reality you are complaining
that the memset was not needed in the first place why is it being used for
-mtune=cortex-a9  when doing -mtune=cortex-a12 can get away with not needing
memset.

Two different issues :).

[Bug target/81907] memset called when it does not need to be; -mtune=cortex-a9

2017-08-21 Thread dongkyun.s at samsung dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81907

--- Comment #9 from dongkyun.s at samsung dot com ---
> or you mean this should be optimized not to use memset; different question 
> from what your summary is about.

I mean -ffreestanding or -fno-freestanding are not included in this testcase,
but, mtune/ mcpu option.
Thanks!

[Bug target/81907] memset called when it does not need to be; -mtune=cortex-a9

2017-08-20 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81907

Andrew Pinski  changed:

   What|Removed |Added

   Keywords||missed-optimization
Summary|undefined reference to  |memset called when it does
   |`memset'|not need to be;
   ||-mtune=cortex-a9
   Severity|normal  |enhancement

--- Comment #8 from Andrew Pinski  ---
>This is not related to freestanding implementations.

Huh?  Since you are not linking against the C library, it has to be.
or you mean this should be optimized not to use memset; different question from
what your summary is about.