473,807 Members | 2,883 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1978
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*******@hotm ail.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_Keit h) 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*******@hotm ail.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....@hotm ail.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
2049
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 list. however this would be very slow for operations like division etc.
11
2554
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 algorithm, when implemented in C or C++. I noticed that the implementation in C is faster by a factor of 2.5 compared to a identical(?) C++-implementation. The basic algorithm in C is:
54
8384
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 creates a big hole in a 32-bit timer routine I wrote. Questions. 1. Why does this happen? 2. Is there C macros/functions I can call to tell me when two non-zero numbers are multiplied and the
9
8003
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
8030
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 multiplication, however, I haven't found any good descriptions for the signed counterpart. Does any of you have a good reference for this topic? Thanks in advance,
5
1570
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) multiplication operations as in: if a == 0 return 0 if a == 1 return b return a*b
19
9927
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, the printf library will not be linked, so it further reduces the executable size. Is there an easy way to disable printf in a large project? In my project, we have thousands of C & C++ files. They don't have a common included common header. ...
7
7592
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 the other one 40000x3. the program runs too slow: /*multiply two matrice: xyz_trans * xyz , the output is w 3x3*/
1
9172
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 recMultiply(int i, int j, float a, int k, int l, float b, int x, int y, float c, int s); int i, j, k, s, matrixsize, blocksize, jj, kk, power, bsize; float sum, maxr, total=0.0, startmult, finishmult, multtime; float* A = NULL; float* B = NULL;
0
9720
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9599
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10374
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10112
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3854
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.