Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiler Optimization of Deterministic Functions

I was reading about Deterministic Execution, which is that for the same input, you have the same output. I was wondering whether any compiler writer has thought about optimizing deterministic functions at runtime. For example, take the factorial function. If at runtime, it is detected that it is continuously being called with the same input value, the compiler can cache the output value and instead of executing the factorial function, can directly use that output value. Seems like a nice research topic. Are there any papers or work on this topic?

like image 842
MetallicPriest Avatar asked Jul 16 '26 06:07

MetallicPriest


1 Answers

This is usually called memoization, and is a fairly common optimization in functional languages.

like image 61
Chris Dodd Avatar answered Jul 22 '26 20:07

Chris Dodd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!