Re: Optimization question

2016-09-27 Thread Florian Weimer
* Nikolaus Dunn: > I've run into an issue where turning on compiler optimization using > -O1 or higher causes an issue in my program. Specifically, I am > replacing the new and delete operators globally to perform some real > time allocation tracking. When I compile with -O1 or -O2, my > implement

Optimization question

2016-09-27 Thread Nikolaus Dunn
Hi guys, I've run into an issue where turning on compiler optimization using -O1 or higher causes an issue in my program. Specifically, I am replacing the new and delete operators globally to perform some real time allocation tracking. When I compile with -O1 or -O2, my implementation of new

Re: optimization question

2015-05-21 Thread Martin Uecker
Am Thu, 21 May 2015 07:45:19 -0500 schrieb mark maule : > > > On 5/20/2015 2:13 PM, Martin Uecker wrote: > > mark maule : > >> On 5/20/2015 3:27 AM, Richard Biener wrote: > >>> On Mon, May 18, 2015 at 10:01 PM, mark maule > >>> wrote: > >>> The usual issue with this kind of behavior is out-o

Re: optimization question

2015-05-21 Thread mark maule
On 5/20/2015 2:13 PM, Martin Uecker wrote: mark maule : On 5/20/2015 3:27 AM, Richard Biener wrote: On Mon, May 18, 2015 at 10:01 PM, mark maule wrote: The usual issue with this kind of behavior is out-of-bound accesses of arrays in a loop or invoking undefined behavior when signed integer

Re: optimization question

2015-05-20 Thread Martin Uecker
mark maule : > On 5/20/2015 3:27 AM, Richard Biener wrote: > > On Mon, May 18, 2015 at 10:01 PM, mark maule wrote: > > The usual issue with this kind of behavior is out-of-bound accesses of > > arrays in a loop > > or invoking undefined behavior when signed integer operations wrap. > > > > > >

Re: optimization question

2015-05-20 Thread Andrew Haley
On 05/20/2015 01:04 PM, mark maule wrote: > Is this one of those areas where if > there's a bug in the code all bets are off and your mileage may vary? Yes. Do not access beyond the end of an array: daemons may fly out of your nose. [1] Andrew. [1] https://groups.google.com/forum/?hl=en#!msg/

Re: optimization question

2015-05-20 Thread mark maule
On 5/20/2015 3:27 AM, Richard Biener wrote: On Mon, May 18, 2015 at 10:01 PM, mark maule wrote: I have a loop which hangs when compiled with -O2, but runs fine when compiled with -O1. Not sure what information is required to get an answer, so starting with the full src code. I have not atte

Re: optimization question

2015-05-20 Thread Richard Biener
On Mon, May 18, 2015 at 10:01 PM, mark maule wrote: > I have a loop which hangs when compiled with -O2, but runs fine when > compiled with -O1. Not sure what information is required to get an answer, > so starting with the full src code. I have not attempted to reduce to a > simpler test case ye

Re: optimization question

2015-05-19 Thread mark maule
On 5/19/2015 10:28 AM, Andrew Haley wrote: On 05/19/2015 04:14 PM, mark maule wrote: Thanks again Martin. I started going down that road yesterday, and got lost in the forest of options. What I was looking for was some option that would tell me what was being done with dgHandle specifically

Re: optimization question

2015-05-19 Thread Andrew Haley
On 05/19/2015 04:14 PM, mark maule wrote: > Thanks again Martin. I started going down that road yesterday, and got > lost in the forest of options. What I was looking for was some option > that would tell me what was being done with dgHandle specifically. I > played around with -fopt-info-al

Re: optimization question

2015-05-19 Thread mark maule
On 5/19/2015 10:09 AM, Martin Sebor wrote: I'm not very familiar with the optimizations that are done in O2 vs O1, or even what happens in these optimizations. So, I'm wondering if this is a bug, or a subtle valid optimization that I don't understand. Any help would be appreciated. Another

Re: optimization question

2015-05-19 Thread Martin Sebor
I'm not very familiar with the optimizations that are done in O2 vs O1, or even what happens in these optimizations. So, I'm wondering if this is a bug, or a subtle valid optimization that I don't understand. Any help would be appreciated. Another approach to debugging a suspected optimization

Re: optimization question

2015-05-18 Thread Kugan
On 19/05/15 12:58, mark maule wrote: > Thank you for taking a look Martin. I will attempt to pare this down, > provide a sample with typedefs/macros expanded, etc. and repost to > gcc-help. To address a couple of your points: If you haven’t already, you can have a look at https://gcc.gnu.org/

Re: optimization question

2015-05-18 Thread mark maule
Thank you for taking a look Martin. I will attempt to pare this down, provide a sample with typedefs/macros expanded, etc. and repost to gcc-help. To address a couple of your points: This code does work when compiled -O2 with 4.4.6 (failing is 4.8.3). It also works on 4.8.3 when dgHandle is

Re: optimization question

2015-05-18 Thread Martin Sebor
On 05/18/2015 02:01 PM, mark maule wrote: I have a loop which hangs when compiled with -O2, but runs fine when compiled with -O1. Not sure what information is required to get an answer, so starting with the full src code. I have not attempted to reduce to a simpler test case yet. Typically a

Re: fast-math optimization question

2014-10-10 Thread Richard Biener
On Fri, Oct 10, 2014 at 3:27 PM, Vincent Lefevre wrote: > On 2014-10-10 11:07:52 +0200, Jakub Jelinek wrote: >> Though, is such optimization desirable even for fast-math? > > I wonder whether fast-math has a well-defined spec, but it should be > noted that because of possible cancellations, even i

Re: fast-math optimization question

2014-10-10 Thread Vincent Lefevre
On 2014-10-10 11:07:52 +0200, Jakub Jelinek wrote: > Though, is such optimization desirable even for fast-math? I wonder whether fast-math has a well-defined spec, but it should be noted that because of possible cancellations, even if the final result is a float, it may be better to keep intermedi

Re: fast-math optimization question

2014-10-10 Thread Jakub Jelinek
On Thu, Oct 09, 2014 at 03:55:34PM -0700, Steve Ellcey wrote: > On Thu, 2014-10-09 at 19:50 +, Joseph S. Myers wrote: > > On Thu, 9 Oct 2014, Steve Ellcey wrote: > > > > > Do you know which pass does the simple > > > '(float)function((double)float_val)' demotion? Maybe that would be a > > > g

Re: fast-math optimization question

2014-10-10 Thread Richard Biener
On Fri, Oct 10, 2014 at 12:55 AM, Steve Ellcey wrote: > On Thu, 2014-10-09 at 19:50 +, Joseph S. Myers wrote: >> On Thu, 9 Oct 2014, Steve Ellcey wrote: >> >> > Do you know which pass does the simple >> > '(float)function((double)float_val)' demotion? Maybe that would be a >> > good place to

Re: fast-math optimization question

2014-10-09 Thread Steve Ellcey
On Thu, 2014-10-09 at 19:50 +, Joseph S. Myers wrote: > On Thu, 9 Oct 2014, Steve Ellcey wrote: > > > Do you know which pass does the simple > > '(float)function((double)float_val)' demotion? Maybe that would be a > > good place to extend things. > > convert.c does such transformations. May

Re: fast-math optimization question

2014-10-09 Thread Joseph S. Myers
On Thu, 9 Oct 2014, Steve Ellcey wrote: > Do you know which pass does the simple > '(float)function((double)float_val)' demotion? Maybe that would be a > good place to extend things. convert.c does such transformations. Maybe the transformations in there could move to the match-and-simplify in

Re: fast-math optimization question

2014-10-09 Thread Richard Biener
On October 9, 2014 8:40:49 PM CEST, Andrew Pinski wrote: >On Thu, Oct 9, 2014 at 11:32 AM, Steve Ellcey wrote: >> On Thu, 2014-10-09 at 11:27 -0700, Andrew Pinski wrote: >> >>> > Is there a reason why GCC couldn't (under -ffast-math) call the >single >>> > precision routines for the first case? >

Re: fast-math optimization question

2014-10-09 Thread Andrew Pinski
On Thu, Oct 9, 2014 at 11:32 AM, Steve Ellcey wrote: > On Thu, 2014-10-09 at 11:27 -0700, Andrew Pinski wrote: > >> > Is there a reason why GCC couldn't (under -ffast-math) call the single >> > precision routines for the first case? >> >> There is no reason why it could not. The reason why it doe

Re: fast-math optimization question

2014-10-09 Thread Steve Ellcey
On Thu, 2014-10-09 at 11:27 -0700, Andrew Pinski wrote: > > Is there a reason why GCC couldn't (under -ffast-math) call the single > > precision routines for the first case? > > There is no reason why it could not. The reason why it does not > currently is because there is no pass which does the

Re: fast-math optimization question

2014-10-09 Thread Andrew Pinski
On Thu, Oct 9, 2014 at 11:23 AM, Steve Ellcey wrote: > I have a -ffast-math (missing?) optimization question. I noticed on MIPS > that if I compiled: > > #include > extern x; > void foo() { x = sin(log(x)); } > > GCC will extend 'x' to

fast-math optimization question

2014-10-09 Thread Steve Ellcey
I have a -ffast-math (missing?) optimization question. I noticed on MIPS that if I compiled: #include extern x; void foo() { x = sin(log(x)); } GCC will extend 'x' to double precision, call the double precision log and sin functions and then truncate the

Re: Loop induction variable optimization question

2013-06-20 Thread Steve Ellcey
On Thu, 2013-06-20 at 03:16 -0700, Stephen Clarke wrote: > > why (and where) did ivopts decide to move the post-increments above the > > usages in the first loop? > > It looks rather like the transformation described next to > tree-ssa-loop-ivopts.c/adjust_iv_update_pos. Yes, that looks like th

Re: Loop induction variable optimization question

2013-06-20 Thread Stephen Clarke
> why (and where) did ivopts decide to move the post-increments above the > usages in the first loop? It looks rather like the transformation described next to tree-ssa-loop-ivopts.c/adjust_iv_update_pos.

Re: Loop induction variable optimization question

2013-06-17 Thread Chung-Ju Wu
2013/6/18 Steve Ellcey : > On Mon, 2013-06-17 at 21:36 +0200, Oleg Endo wrote: > >> >> Sorry for not having an answer. I got curious, because just yesterday I >> was looking at this one >> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55190 >> and thought that this is related, although it doesn't se

Re: Loop induction variable optimization question

2013-06-17 Thread Steve Ellcey
On Mon, 2013-06-17 at 21:36 +0200, Oleg Endo wrote: > > Sorry for not having an answer. I got curious, because just yesterday I > was looking at this one > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55190 > and thought that this is related, although it doesn't seem to. > I've tried the two func

Re: Loop induction variable optimization question

2013-06-17 Thread Oleg Endo
On Mon, 2013-06-17 at 10:07 -0700, Steve Ellcey wrote: > I have a loop induction variable question involving post increment. > If I have this loop: > > [...] > My question is is: why (and where) did ivopts decide to move the > post-increments above the usages in the first loop? In my case > (MIP

Loop induction variable optimization question

2013-06-17 Thread Steve Ellcey
I have a loop induction variable question involving post increment. If I have this loop: void *memcpy_word_ptr(int * __restrict d, int * __restrict s, unsigned int n ) { int i; for(i=0; i: # d_22 = PHI # s_23 = PHI # i_24 = PHI d_10 = d_22 + 4; s_11 = s_23 + 4; _12 = *s_23; *

RE: optimization question: mpl

2011-10-17 Thread Hite, Christopher
> void foo<0>(int id, DecodeContext& dc) {} int main(){ DecodeContext& dc= *(DecodeContext*)0;// junk for now int id=std::rand(); // runtime dependent foo<50>(id,dc); return 0; } -Original Message- From: Piotr Rak [mailto:piotr@gma

Re: optimization question: mpl

2010-07-29 Thread Larry Evans
On 07/28/10 10:26, Richard Guenther wrote: [snip] You can use the flatten attribute to tell the compiler to inline all calls in a given function, like void __attribute__((flatten)) foo(void) { ... decode1(); ... } and it will inline decode1() (and recursively all its callees). [snip] Will th

Re: optimization question: mpl

2010-07-28 Thread Larry Evans
On 07/28/10 13:16, Piotr Rak wrote: [snip] Or you could just initialize static array of pointers, like that (please note, that I never compiled code below): [snip] Piotr, something similar was proposed here: http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/364c0dd5

Re: optimization question: mpl

2010-07-28 Thread Piotr Rak
Hi, 2010/7/28 Hite, Christopher : >> Generally without knowing the compiler version you are using >> it is hard to tell. > I'll use whatever's best.  Right now I'm still on 4.4.3.  I'll probably > upgrade soon to 4.5. > >> The same is true without a complete compilable testcase. > I didn't want to

Re: optimization question: mpl

2010-07-28 Thread Larry Evans
On 07/28/10 10:53, Hite, Christopher wrote: [snip] struct DecodeContext; struct M1{ static const int id=1; static void decode(DecodeContext& ){} }; struct M2{ static const int id=2; static void decode(DecodeContext& ){} }; struct M3{ static const int id=

RE: optimization question: mpl

2010-07-28 Thread Hite, Christopher
> Generally without knowing the compiler version you are using > it is hard to tell. I'll use whatever's best. Right now I'm still on 4.4.3. I'll probably upgrade soon to 4.5. > The same is true without a complete compilable testcase. I didn't want to make a test case that depends on boost::mp

Re: optimization question: mpl

2010-07-28 Thread Larry Evans
On 07/28/10 09:37, Hite, Christopher wrote: [snip] I'm tring to use the template compiler to generate equivalent code. I have a mpl::list of packet descriptions like this: struct Packet1{ static const int id=1; void decode(); }; I then use boost::

Re: optimization question: mpl

2010-07-28 Thread Richard Guenther
On Wed, Jul 28, 2010 at 4:37 PM, Hite, Christopher wrote: > > > > I'm writing a decoder using a meta programming techniques alla > boost::mpl and I'd like to know if I'm asking too much of the compiler. > > Basically I've got lots of packet types with different ids.  The > classical way to write t

optimization question: mpl

2010-07-28 Thread Hite, Christopher
I'm writing a decoder using a meta programming techniques alla boost::mpl and I'd like to know if I'm asking too much of the compiler. Basically I've got lots of packet types with different ids. The classical way to write these would be a switch case int id; switch(id){

Re: optimization question

2009-05-19 Thread Richard Guenther
On Tue, May 19, 2009 at 2:02 AM, Daniel Berlin wrote: > On Sat, May 16, 2009 at 5:49 AM, Richard Guenther > wrote: >> On Sat, May 16, 2009 at 11:41 AM, VandeVondele Joost >> wrote: >>> >> I think it is useful to have a bugzilla here. > > will do. >>> >>> http://gcc.gnu.org/bugzilla/

Re: optimization question

2009-05-18 Thread Daniel Berlin
On Sat, May 16, 2009 at 5:49 AM, Richard Guenther wrote: > On Sat, May 16, 2009 at 11:41 AM, VandeVondele Joost > wrote: >> > I think it is useful to have a bugzilla here. will do. >> >> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40168 >> >>> >>> Btw, complete unrolling is also hi

Re: optimization question

2009-05-16 Thread Richard Guenther
On Sat, May 16, 2009 at 11:41 AM, VandeVondele Joost wrote: > I think it is useful to have a bugzilla here. >>> >>> will do. > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40168 > >> >> Btw, complete unrolling is also hindred by the artificial limit of >> maximally >> unrolling 16 iterations

Re: optimization question

2009-05-16 Thread VandeVondele Joost
I think it is useful to have a bugzilla here. will do. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40168 Btw, complete unrolling is also hindred by the artificial limit of maximally unrolling 16 iterations. Your inner loops iterate 27 times. Also by the artificial limit of the maximal u

Re: optimization question

2009-05-16 Thread Richard Guenther
On Sat, May 16, 2009 at 11:29 AM, VandeVondele Joost wrote: > > > thanks for the info > >> I think it is useful to have a bugzilla here. > > will do. Btw, complete unrolling is also hindred by the artificial limit of maximally unrolling 16 iterations. Your inner loops iterate 27 times. Also by

Re: optimization question

2009-05-16 Thread VandeVondele Joost
thanks for the info I think it is useful to have a bugzilla here. will do. I tested 4.4, what did you test? 4.3 4.4 4.5 Joost

Re: optimization question

2009-05-16 Thread Richard Guenther
On Sat, May 16, 2009 at 10:28 AM, VandeVondele Joost wrote: > the attached code (see contract__sparse) is a kernel which I hope gets > optimized well. Unfortunately, compiling (on opteron or core2) it as > > gfortran -O3 -march=native -ffast-math -funroll-loops -ffree-line-length-200 >  test.f

optimization question

2009-05-16 Thread VandeVondele Joost
the attached code (see contract__sparse) is a kernel which I hope gets optimized well. Unfortunately, compiling (on opteron or core2) it as gfortran -O3 -march=native -ffast-math -funroll-loops -ffree-line-length-200 test.f90 ./a.out Sparse: time[s] 0.66804099 New: time[s] 0.2080

Re: An optimization question

2009-05-08 Thread Andrew Haley
Dave Korn wrote: > Andrew Haley wrote: >> Dave Korn wrote: > >>> So, this is a real bug then - but it's a missed optimisation in the first >>> case, not a bogus one in the second case? >> Probably, but it's not a very interesting one. For what it's worth, the >> tree dumps are identical right u

Re: An optimization question

2009-05-08 Thread Dave Korn
Andrew Haley wrote: > Dave Korn wrote: >> So, this is a real bug then - but it's a missed optimisation in the first >> case, not a bogus one in the second case? > > Probably, but it's not a very interesting one. For what it's worth, the > tree dumps are identical right up to the very last tree

Re: An optimization question

2009-05-08 Thread Andrew Haley
Dave Korn wrote: > Andrew Haley wrote: >> eCos@ wrote: > >>> === >>> int *p; >>> >>> int main(void) >>> { >>> p++; >>> __asm__ __volatile__ (""::); >>> p++; >>> } >>> === > >>> assembly

Re: An optimization question

2009-05-07 Thread Richard Guenther
On Thu, May 7, 2009 at 3:05 PM, Andrew Haley wrote: > Dave Korn wrote: >> Andrew Haley wrote: >>> eCos@ wrote: >> === int *p; int main(void) {         p++;         __asm__ __volatile__ (""::);         p++; } >

Re: An optimization question

2009-05-07 Thread Andrew Haley
Dave Korn wrote: > Andrew Haley wrote: >> eCos@ wrote: > >>> === >>> int *p; >>> >>> int main(void) >>> { >>> p++; >>> __asm__ __volatile__ (""::); >>> p++; >>> } >>> === > >>> assembly

Re: An optimization question

2009-05-07 Thread Dave Korn
Andrew Haley wrote: > eCos@ wrote: >> === >> int *p; >> >> int main(void) >> { >> p++; >> __asm__ __volatile__ (""::); >> p++; >> } >> === >> assembly code is like: >> 'addl $4, %eax'

Re: An optimization question

2009-05-07 Thread Andrew Haley
e...@sunnorth.com.cn wrote: > Here is an optimization question about gcc compiler, we wonder whether it > is a bug or not. > > A simple test program here: > === > int *p; > > int main(void) > { > p++;

An optimization question

2009-05-07 Thread eCos
Hi Here is an optimization question about gcc compiler, we wonder whether it is a bug or not. A simple test program here: === int *p; int main(void) { p++; __asm__ __volatile__ (""::);

Re: Interprocedural optimization question

2007-01-30 Thread Ramon Bertran Monfort
El Mon, Jan 29, 2007 at 02:28:34PM -0500, Daniel Berlin ens deleit� amb les seg�ents paraules: > On 1/29/07, Razya Ladelsky <[EMAIL PROTECTED]> wrote: >> Razya Ladelsky/Haifa/IBM wrote on 29/01/2007 13:46:33: >> >>> Hi, >>> >>> Does gcc apply inter-procedural optimizations across functions call

Re: Interprocedural optimization question

2007-01-29 Thread Daniel Berlin
On 1/29/07, Razya Ladelsky <[EMAIL PROTECTED]> wrote: Razya Ladelsky/Haifa/IBM wrote on 29/01/2007 13:46:33: > Hi, > > Does gcc apply inter-procedural optimizations across functions called using > a function pointer? I guess that gcc performs conservatively assuming that > the pointer could poin

RE: Interprocedural optimization question

2007-01-29 Thread Razya Ladelsky
Razya Ladelsky/Haifa/IBM wrote on 29/01/2007 13:46:33: > Hi, > > Does gcc apply inter-procedural optimizations across functions called using > a function pointer? I guess that gcc performs conservatively assuming that > the pointer could point everywhere because the pointer is a declared as

Interprocedural optimization question

2007-01-29 Thread Ramon Bertran Monfort
Hi, Does gcc apply inter-procedural optimizations across functions called using a function pointer? I guess that gcc performs conservatively assuming that the pointer could point everywhere because the pointer is a declared as a global variable and could be changed in any place. Is it true? In

Re: Thumb optimization question

2006-01-03 Thread Richard Earnshaw
On Mon, 2005-12-26 at 21:41, Ivan Petrov wrote: > I have one question. So... have small sample programm. > > [code] > int bar( int ); > > int foo( int a, int b ) > { >return bar( a + b ); > } > [/code] > > If I compille it with out -thumb parameter, i have very clean code. > > add r0, r1

Thumb optimization question

2005-12-26 Thread Ivan Petrov
I have one question. So... have small sample programm. [code] int bar( int ); int foo( int a, int b ) { return bar( a + b ); } [/code] If I compille it with out -thumb parameter, i have very clean code. add r0, r1, r0 bx lr But with -thumb parameter have unopimized code. add r1, r1, r0 mov