public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/12194] New: Encapsulation penalty should not exist for simple classes
@ 2003-09-06 21:02 yuri at tsoft dot com
  2003-09-06 21:06 ` [Bug c++/12194] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: yuri at tsoft dot com @ 2003-09-06 21:02 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: Encapsulation penalty should not exist for simple
                    classes
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: yuri at tsoft dot com
                CC: gcc-bugs at gcc dot gnu dot org

When I compile the following with -O3
changing TYPE macro from "int" to "C_int"
I see performance penalty from
10% to 100% depending on how many accumulators
(res variables) with the same number of total
multiplications.

Modifications with smaller array size and longer
repetitions of overall arrays do not change the
trend.

This should NOT occur for such a simplistic
class having only one integer inside.


Yuri

---------------------------------------------------

#include <stdio.h>

class C_int {
public:
  int i;
  inline C_int() { }
  inline C_int(int new_i) { i = new_i; }
  inline C_int operator*(C_int i1) {
    C_int ii(i*i1.i);
    return (ii);
  }
  inline C_int operator+(C_int i1) {
    C_int ii(i+i1.i);
    return (ii);
  }
  inline void operator+=(C_int i1) {
    i += i1.i;
  }
  inline void operator=(int ii) { i = ii; }
//  inline void operator(int)() { return (i); }
};

#define TYPE int  // 1
//#define TYPE C_int  // 2
#define SZ 30000000

TYPE v1[SZ];
TYPE v2[SZ];

int
main(int argc, const char *argv[]) {

  { // initialize
    for (int i = 0; i < SZ; i++) {
      v1[i] = i^0x010101 + 0x437785;
      v2[i] = i^0x017132 + 0x245726;
    }
  }

  TYPE res = 0;
  { // inner product
    for (int i = 0; i < SZ; i++) {
      res += v1[i] * v2[i];
    }
  }

//  printf("res=%i\n", res.i);
  return (0);
}


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/12194] Encapsulation penalty should not exist for simple classes
  2003-09-06 21:02 [Bug c++/12194] New: Encapsulation penalty should not exist for simple classes yuri at tsoft dot com
@ 2003-09-06 21:06 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-09-06 21:06 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-09-06 21:06 -------
Can you stop sending dup of your own bugs?

*** This bug has been marked as a duplicate of 12190 ***


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-09-06 21:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-06 21:02 [Bug c++/12194] New: Encapsulation penalty should not exist for simple classes yuri at tsoft dot com
2003-09-06 21:06 ` [Bug c++/12194] " pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).