Skip to main content
typo corrected
Source Link
gnat
  • 20.5k
  • 29
  • 117
  • 310

Are there compilers which optimize the use of mathmaticalmathematical functions?

Today while programming I stumbled upon the following question - are there any compilers which optimize based on mathmaticalmathematical assumptions?

For instance in cases like

unsigned int i,b;
(i,b not constant)
if(sqrt(i) == b)
...

In this case it would be a lot more effective to use

unsigned int i,b;
(i,b not constant)
if(i == b*b)
...

Assuming a sqrt() function, that handles unsigned integers and rounds sensefully.

Since I was not able to find useful information (probably because I did not know what to search for specifically), can someone please tell me or point me to a relevant source? Are

Are there compilers (for imperative languages) who optimize such things using some kind of heuristic? Or more specifically - what about gcc and microsoft visual c++ and matlab?

Are there compilers which optimize the use of mathmatical functions?

Today while programming I stumbled upon the following question - are there any compilers which optimize based on mathmatical assumptions?

For instance in cases like

unsigned int i,b;
(i,b not constant)
if(sqrt(i) == b)
...

In this case it would be a lot more effective to use

unsigned int i,b;
(i,b not constant)
if(i == b*b)
...

Assuming a sqrt() function, that handles unsigned integers and rounds sensefully.

Since I was not able to find useful information (probably because I did not know what to search for specifically), can someone please tell me or point me to a relevant source? Are there compilers (for imperative languages) who optimize such things using some kind of heuristic? Or more specifically - what about gcc and microsoft visual c++ and matlab?

Are there compilers which optimize the use of mathematical functions?

Today while programming I stumbled upon the following question - are there any compilers which optimize based on mathematical assumptions?

For instance in cases like

unsigned int i,b;
(i,b not constant)
if(sqrt(i) == b)
...

In this case it would be a lot more effective to use

unsigned int i,b;
(i,b not constant)
if(i == b*b)
...

Assuming a sqrt() function, that handles unsigned integers and rounds sensefully.

Since I was not able to find useful information (probably because I did not know what to search for specifically), can someone please tell me or point me to a relevant source?

Are there compilers (for imperative languages) who optimize such things using some kind of heuristic? Or more specifically - what about gcc and microsoft visual c++ and matlab?

added 132 characters in body
Source Link

Today while programming I stumbled upon the following question - are there any compilers which optimize based on mathmatical assumptions?

For instance in cases like

unsigned int i,b;
(i,b not constant)
if(sqrt(i) == b)
...

In this case it would be a lot more effective to use

unsigned int i,b;
(i,b not constant)
if(i == b*b)
...

Assuming a sqrt() function, that handles unsigned integers and rounds sensefully.

Since I was not able to find useful information (probably because I did not know what to search for specifically), can someone please tell me or point me to a relevant source? Are there compilers (for imperative languages) who optimize such things using some kind of heuristic? Or more specifically - what about gcc and microsoft visual c++ and matlab?

Today while programming I stumbled upon the following question - are there any compilers which optimize based on mathmatical assumptions?

For instance in cases like

int i,b;
(i,b not constant)
if(sqrt(i) == b)
...

In this case it would be a lot more effective to use

int i,b;
(i,b not constant)
if(i == b*b)
...

Since I was not able to find useful information (probably because I did not know what to search for specifically), can someone please tell me or point me to a relevant source? Are there compilers (for imperative languages) who optimize such things? Or more specifically - what about gcc and microsoft visual c++ and matlab?

Today while programming I stumbled upon the following question - are there any compilers which optimize based on mathmatical assumptions?

For instance in cases like

unsigned int i,b;
(i,b not constant)
if(sqrt(i) == b)
...

In this case it would be a lot more effective to use

unsigned int i,b;
(i,b not constant)
if(i == b*b)
...

Assuming a sqrt() function, that handles unsigned integers and rounds sensefully.

Since I was not able to find useful information (probably because I did not know what to search for specifically), can someone please tell me or point me to a relevant source? Are there compilers (for imperative languages) who optimize such things using some kind of heuristic? Or more specifically - what about gcc and microsoft visual c++ and matlab?

deleted 6 characters in body
Source Link

Today while programming I stumbled upon the following question - are there any compilers which optimize based on mathmatical assumptions?

For instance in cases like

doubleint i,b;
(i,b not constant)
if(sqrt(i) == b)
...

In this case it would be a lot more effective to use

doubleint i,b;
(i,b not constant)
if(i == b*b)
...

Since I was not able to find useful information (probably because I did not know what to search for specifically), can someone please tell me or point me to a relevant source? Are there compilers (for imperative languages) who optimize such things? Or more specifically - what about gcc and microsoft visual c++ and matlab?

Today while programming I stumbled upon the following question - are there any compilers which optimize based on mathmatical assumptions?

For instance in cases like

double i,b;
(i,b not constant)
if(sqrt(i) == b)
...

In this case it would be a lot more effective to use

double i,b;
(i,b not constant)
if(i == b*b)
...

Since I was not able to find useful information (probably because I did not know what to search for specifically), can someone please tell me or point me to a relevant source? Are there compilers (for imperative languages) who optimize such things? Or more specifically - what about gcc and microsoft visual c++ and matlab?

Today while programming I stumbled upon the following question - are there any compilers which optimize based on mathmatical assumptions?

For instance in cases like

int i,b;
(i,b not constant)
if(sqrt(i) == b)
...

In this case it would be a lot more effective to use

int i,b;
(i,b not constant)
if(i == b*b)
...

Since I was not able to find useful information (probably because I did not know what to search for specifically), can someone please tell me or point me to a relevant source? Are there compilers (for imperative languages) who optimize such things? Or more specifically - what about gcc and microsoft visual c++ and matlab?

Source Link
Loading