473,394 Members | 1,709 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

how to disable the multiplication optimization?

GCC always avoids multiplication instructions as much as possible, so a *= 10; will be translated into:

leal (%eax, %eax, 4), %eax
add %eax, %eax

I do know that it is due to historic reason, for that old CPU spent 30+ clock cycles to finish a multiplication
instruction. But it is never true now, while 3 clock cycles will suffice, so it brings the side affect of bigger object
files without any gain.
It might do it default for the consideration of compatibility, but my problem is how to disable it, for my code will
never run on a box been made a decade ago.

Yixin Cao
Feb 14 '07 #1
4 1965
Yixin Cao wrote:
GCC always avoids multiplication instructions as much as possible, so a
*= 10; will be translated into:

leal (%eax, %eax, 4), %eax
add %eax, %eax
That's a compiler specific feature, bast to ask on gcc list.

--
Ian Collins.
Feb 14 '07 #2
Yixin Cao <yi*******@hotmail.comwrites:
GCC always avoids multiplication instructions as much as possible,
so a *= 10; will be translated into:
[snip]
It might do it default for the consideration of compatibility, but my
problem is how to disable it, for my code will never run on a box been
made a decade ago.
If reading the gcc documentation doesn't answer this, try gnu.gcc.help.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Feb 14 '07 #3
Following is what Intel C Compiler generates:
9: 8d 0c 89 lea (%ecx,%ecx,4),%ecx
c: 8d 04 48 lea (%eax,%ecx,2),%eax

So, it might not a be the gcc only setting.

Anyway, thanks, I have sent this to gnu.gcc.help to try to find an answer.
Keith Thompson wrote:
Yixin Cao <yi*******@hotmail.comwrites:
>GCC always avoids multiplication instructions as much as possible,
so a *= 10; will be translated into:
[snip]
>It might do it default for the consideration of compatibility, but my
problem is how to disable it, for my code will never run on a box been
made a decade ago.

If reading the gcc documentation doesn't answer this, try gnu.gcc.help.
Feb 14 '07 #4
On Feb 14, 3:32 am, Yixin Cao <yixin....@hotmail.comwrote:
GCC always avoids multiplication instructions as much as possible, so a *= 10; will be translated into:

leal (%eax, %eax, 4), %eax
add %eax, %eax

I do know that it is due to historic reason, for that old CPU spent 30+ clock cycles to finish a multiplication
instruction. But it is never true now, while 3 clock cycles will suffice, so it brings the side affect of bigger object
files without any gain.
It might do it default for the consideration of compatibility, but my problem is how to disable it, for my code will
never run on a box been made a decade ago.

Yixin Cao
1. It's still likely to be faster.
2. Did you actually check how many bytes of code are generated in each
case?
3. What about running on the box made a decade from now?

Feb 14 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: I.V. Aprameya Rao | last post by:
hi i have been wondering, how does python store its very long integers and perform aritmetic on it. i needed to implement this myself and was thinking of storing the digits of an integer in a...
11
by: Michael Bader | last post by:
Hi, I'm currently working on a matrix multiplication code (matrix times matrix), and have come along some interesting/confusing results concerning the running time of the (apparently) same...
54
by: Andy | last post by:
Hi, I don't know if this is the correct group to post this, but when I multiply a huge floating point value by a really small (non-zero) floating point value, I get 0 (zero) for the result. This...
9
by: Ralf Hildebrandt | last post by:
Hi all! First of all: I am a C-newbie. I have noticed a "strange" behavior with the standart integer multiplication. The code is: void main(void)
17
by: Christopher Dyken | last post by:
Hi group, I'm trying to implement two routines to handle 32x32-bits and 64x64-bits signed integer multiplication on a 32 bits machine in C. It easy to find descriptions of non-signed...
5
by: Paul McGuire | last post by:
Does Python's run-time do any optimization of multiplication operations, like it does for boolean short-cutting? That is, for a product a*b, is there any shortcutting of (potentially expensive)...
19
by: RedDevilDan | last post by:
I am working on a Memory Footprint Reduction project. I came across an idea to disable all printf statements so that less memory is required. In addition, when there is no single printf statement,...
7
by: VijaKhara | last post by:
Hi all, Is there any method which can implememt the matrix multiplication faster than using the formula as we often do by hand? I am writing the following code and my matrice: one is 3x40000 and...
1
by: Sozos | last post by:
Hi guys. I have a problem with writing the base case for the following matrix multiplication function I have implemented. Please help. #define index(i,j,power) (((i)<<(power))+(j)) void...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.