Gentoo Archives: gentoo-performance

From: Andrea Pretto <prettz_it@×××××.it>
To: gentoo-performance@l.g.o
Subject: Re: [gentoo-performance] gcc optimizations
Date: Wed, 30 Jun 2004 17:35:22
Message-Id: 20040630173518.30460.qmail@web25110.mail.ukl.yahoo.com
In Reply to: [gentoo-performance] gcc optimizations by Paul Ingelbrant
1 The flag -mmmx ( like -msse -m3dnow etc...) activate
2 some extensions for C language.
3
4 See this:
5 http://gcc.gnu.org/onlinedocs/gcc-3.3.3/gcc/X86-Built-in-Functions.html#X86%20Built-in%20Functions
6
7 So, those flag activate these built-in functions.
8
9 --- Paul Ingelbrant <pi@×××××.se> ha scritto: >
10 >
11 >
12 > I've been thinking about CFLAGS such as -mmmx...
13 > Does gcc actually have the
14 > ability to actually produce mmx instructions?
15 >
16 >
17 > for example:
18 >
19 >
20 > mmx.c:
21 >
22 > #include <stdio.h>
23 >
24 >
25 > main()
26 > {
27 > short x[100000];
28 > int i;
29 >
30 > for (i=0; i < 100000; i++)
31 > {
32 > x[i] += 5;
33 >
34 > }
35 >
36 >
37 > }
38 >
39 > gcc -mmmx -O3 --save-temps -funroll-all-loops mmx.c
40 > gives
41 >
42 >
43 > .file "mmx.c"
44 > .def ___main; .scl 2; .type 32; .endef
45 > .text
46 > .align 2
47 > .p2align 4,,15
48 > .globl _main
49 > .def _main; .scl 2; .type 32; .endef
50 > _main:
51 > pushl %ebp
52 > movl $200008, %eax
53 > movl %esp, %ebp
54 > call __alloca
55 > xorl %eax, %eax
56 > andl $-16, %esp
57 > call __alloca
58 > call ___main
59 > xorl %eax, %eax
60 > .p2align 4,,7
61 > L6:
62 > addw $5, -200008(%ebp,%eax,2)
63 > addw $5, -200006(%ebp,%eax,2)
64 > addw $5, -200004(%ebp,%eax,2)
65 > addw $5, -200002(%ebp,%eax,2)
66 > addw $5, -200000(%ebp,%eax,2)
67 > addw $5, -199998(%ebp,%eax,2)
68 > addw $5, -199996(%ebp,%eax,2)
69 > addw $5, -199994(%ebp,%eax,2)
70 > addw $5, -199992(%ebp,%eax,2)
71 > addw $5, -199990(%ebp,%eax,2)
72 > addl $10, %eax
73 > cmpl $99999, %eax
74 > jle L6
75 > leave
76 > ret
77 >
78 >
79 >
80 >
81 > Shouldn't take too much imagination to see how that
82 > could be improved with mmx...
83 >
84 > Likewise:
85 >
86 >
87 >
88 > fu(int *x)
89 > {
90 > if (*x == 5)
91 > *x = 10;
92 > }
93 >
94 >
95 >
96 > with gcc -march=athlon-xp -O3 --save-temps
97 > -funroll-all-loops mmx.c
98 >
99 > gives
100 >
101 >
102 >
103 > _fu:
104 > pushl %ebp
105 > movl %esp, %ebp
106 > movl 8(%ebp), %eax
107 > cmpl $5, (%eax)
108 > je L33
109 > L32:
110 > leave
111 > ret
112 > .p2align 6,,7
113 > L33:
114 > movl $10, (%eax)
115 > jmp L32
116 >
117 >
118 > the -march=athlon-xp parameter should imply cmov
119 > instruction...(?)
120 >
121 >
122 > (it doesn't even use muliple leave/ret to eliminate
123 > an extra jmp...)
124 >
125 >
126 >
127 > Do the gcc developers include these fancy parameters
128 > just to give us ricers a
129 > false sense of speed?
130 >
131 >
132 > any thoughts?
133 >
134 >
135 >
136 > --
137 > gentoo-performance@g.o mailing list
138 >
139 >
140
141
142
143
144
145
146 ____________________________________________________________
147 Yahoo! Companion - Scarica gratis la toolbar di Ricerca di Yahoo!
148 http://companion.yahoo.it
149
150 --
151 gentoo-performance@g.o mailing list

Replies

Subject Author
Re: [gentoo-performance] gcc optimizations Paul Ingelbrant <pi@×××××.se>