This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/32044] New: udivdi3 counterproductive, unwarranted use


First I am herewith re-afirming my formal request for Mr. Pinsk to refrain from
having anything to do with my submissions.

Now to the heart of the matter:

According to my (admittedly second hand (Fifth Edition of "C A Reference
Manual"
by Samuel P. Harbison III & Guy L. Stelle Jr) reading; GCC, by not providing a 
means to disable the use of libgcc (including udivdi3) is not in strict 
conformance with the C standard for free-standing use through C99. __udivdi3 is
a reserved identifier 
and hence non-conforming.

The irony is that, besides, being non-conforming and prejudicing free standing 
applications that aim for maximum portability, it is highly counterproductive 
in its own right.

Also, the forced and silent use of libgcc (lld does not show it being used) 
violates one of the fundamental principles of both UNIX and C. Namely that 
the user (certainly root) is to be in full and absolute command of the system 
without hidden reinterpretation of his commands or MS type questions.  As a 
practical matter the use of __builtin_expect could be taken as signal to 
allow only reordering of instructions (to avoid pipeline stalls and 
reloading of caches) are to be avoided in the marked unlikely cases. Any 
fundamental changes like exchanging a while and a subtraction for a
non-hardware 
divide should no occur

If anybody at GCC wants to know what others (including L. Torvalds and A.
Morton) think; checking Google on udivdi3 might be instructive.

What follows are the result of tests using current versions of gcc-4.3 and
4.2.1. 
I believe the results speak for themselves. Besides the data for x86 I also 
have quite similar data for powerpc G4,  which I will make available as a
follow on.

        Program

#define NSEC_PER_SEC  1000000000UL      
int rmg(void);

int main(void)
{
        /* int sec; */
        return rmg();
}

int rmg(void)
{
static unsigned long long nsec = 0;
static int sec = 0;
    while (sec < 1 ) { 
        nsec++;
        while (__builtin_expect(nsec >= NSEC_PER_SEC, 0)) {
                nsec -= NSEC_PER_SEC;
                ++sec;
        }
    }   
        return sec;
}


        gcc_43 -O0

-rwxr-xr-x 1 root root  8478 2007-05-22 08:23 rmgg_O0
-rw-r--r-- 1 root root  1238 2007-05-22 08:18 rmgg_O0.s

real    0m27.613s
user    0m27.607s
sys     0m0.003s


        gcc_43 -O1

-rwxr-xr-x 1 root root 12586 2007-05-22 08:25 rmgg_O1
-rw-r--r-- 1 root root  1572 2007-05-22 08:25 rmgg_O1.s

real    0m12.776s
user    0m12.775s
sys     0m0.003s

        gcc_43 -O2

-rwxr-xr-x 1 root root 12586 2007-05-22 08:27 rmgg_O2
-rw-r--r-- 1 root root  1874 2007-05-22 08:27 rmgg_O2.s

real    0m16.415s
user    0m16.414s
sys     0m0.004s

        gcc_43 -Os

-rwxr-xr-x 1 root root 12586 2007-05-22 08:29 rmgg_Os
-rw-r--r-- 1 root root  1925 2007-05-22 08:29 rmgg_Os.s

real    2m8.817s
user    2m8.831s
sys     0m0.003s



        Program

#define NSEC_PER_SEC  1000000000UL      
int rmg(void);

int main(void)
{
        /* int sec; */
        return rmg();
}

int rmg(void)
{
static unsigned long long nsec = 0;
static int sec = 0;
    while (sec < 1 ) { 
        nsec++;
        while (__builtin_expect(nsec >= NSEC_PER_SEC, 0)) {
                nsec -= NSEC_PER_SEC;
                ++sec;
        }
    }   
        return sec;
}

        gcc_42 -O0

-rwxr-xr-x 1 root root 8471 2007-05-21 16:46 rmgg_O0
-rw-r--r-- 1 root root 1236 2007-05-21 16:41 rmgg_O0.s
time ./rmgg_O0

real    0m27.678s
user    0m27.680s
sys     0m0.002s
Script done on Mon 21 May 2007 04:53:29 PM EDT



        gcc_42 -O1 

-rwxr-xr-x 1 root root 8471 2007-05-21 16:41 rmgg_O1
-rw-r--r-- 1 root root 1572 2007-05-22 09:39 rmgg_O1.s

Script started on Mon 21 May 2007 04:56:20 PM EDT
time ./rmgg_O1

real    0m12.771s
user    0m12.767s
sys     0m0.003s
Script done on Mon 21 May 2007 04:56:55 PM EDT



        gcc_42 -O2

-rwxr-xr-x 1 root root 8471 2007-05-21 16:41 rmgg_O2
-rw-r--r-- 1 root root 1262 2007-05-21 17:41 rmgg_O2.s
Script started on Mon 21 May 2007 04:57:14 PM EDT
time ./rmgg_O2

real    0m12.532s
user    0m12.531s
sys     0m0.003s
Script done on Mon 21 May 2007 04:58:18 PM EDT



        gcc -Os

-rwxr-xr-x 1 root root 8471 2007-05-21 16:41 rmgg_Os
-rw-r--r-- 1 root root 1017 2007-05-21 16:40 rmgg_Os.s
Script started on Mon 21 May 2007 04:58:30 PM EDT
time ./rmgg_O2

real    0m12.571s
user    0m12.562s
sys     0m0.004s
Script done on Mon 21 May 2007 04:59:11 PM EDT


-- 
           Summary: udivdi3 counterproductive, unwarranted use
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: malitzke at metronets dot com
 GCC build triplet: i686-pc-linux.gnu
  GCC host triplet: i686-pc-linux.gnu
GCC target triplet: i686-pc-linux.gnu


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]