Click here to Skip to main content
15,886,963 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: What about using AI to optimize compiler code generation? Pin
honey the codewitch17-Oct-23 3:01
mvahoney the codewitch17-Oct-23 3:01 
GeneralRe: What about using AI to optimize compiler code generation? Pin
jschell17-Oct-23 6:17
jschell17-Oct-23 6:17 
GeneralRe: What about using AI to optimize compiler code generation? Pin
honey the codewitch17-Oct-23 6:26
mvahoney the codewitch17-Oct-23 6:26 
GeneralRe: What about using AI to optimize compiler code generation? Pin
trønderen17-Oct-23 7:48
trønderen17-Oct-23 7:48 
GeneralRe: What about using AI to optimize compiler code generation? Pin
jschell18-Oct-23 5:43
jschell18-Oct-23 5:43 
GeneralRe: What about using AI to optimize compiler code generation? Pin
trønderen18-Oct-23 12:41
trønderen18-Oct-23 12:41 
GeneralRe: What about using AI to optimize compiler code generation? Pin
jschell19-Oct-23 5:00
jschell19-Oct-23 5:00 
GeneralRe: What about using AI to optimize compiler code generation? Pin
trønderen17-Oct-23 7:27
trønderen17-Oct-23 7:27 
Your "problem" is that 99,6% of all the optimizations you think of for an AI is already implemented in today's optimizers, and have been for decades.

Years ago, a paper was presented at a 'History of Programming Language' conference. The presenter told about the development of the first optimizing Fortran compiler, around 1960: The development team frequently sat down to study the code generated, asking each other: How the elephant did the compiler find out that it could do that? They were the ones teaching it, yet they had a feeling of the compiler living its own life.

This was 60+ years ago. Optimizers have learned a lot since then. There has been some interference - the liberty C takes with pointers is like throwing a wrench into the machinery - but learning to handle the noise has made the optimizers even stronger.

Traditionally, optimizers handled a single compilation unit only. Unix promoted the idea of extremely small compilation units, limiting cross-module optimizations. (In other environments, the average module size is usually larger than in Unix environments.) For space optimization, we soon got object code formats where the compilation is not one monolithic block, but can be loaded piecewise, depending on which external symbols are referenced. Furthermore, the compiler leaves metadata in the object format, allowing the linker to make some adaptations, e.g. depending on whether the module makes direct or indirect recursive calls. These are not very significant optimizations for speed, but can be noticeable for space.

Modern IDEs do not consider 20-line C functions (12 of the lines a copyleft statement) in isolation. Have you ever used an advanced static code analysis tool? Maybe it will tell you something like

'In module M1, method Ma in class Cx, on line 256 the method M2.I24.Mb() is called with an X argument of 120. This value, when added to the Y value, which will never exceed 40, and passed to the method M3.J8.Mc() as argument Z, the test at line 442 of this function, if (Z>200) {...} will never be true, so the if clause is dead code. There are no other calls to M3.J8.Mc() with arguments that will cause the condition to be true.'

Or something like that. When your IDE generates a complete assembly, not just a linkable module, it can use such information to remove the dead code, along with the if test, for this assembly. Even when generating a linkable module, when compiling non-public elements, it can do similar tuning (along with e.g. detecting possible NULL references, out-of-bounds indexing, and lots of other possible pitfalls).

Today, the more advanced code analyzers are independent tools, not generating code, but you see more and more of that kind of functionality creeping slowly into IDEs. IDEs also typically make use of database like structures for publishing metadata about modules for which the source code may be unavailable. The compiler address this info for all referenced modules for adapting the code generating to what it finds about the called method.

One optimization available with JIT systems: For a fully compiled, executable program you either cannot make use of architectural extension such as advanced instruction sets, or the program must have code both using the extensions and for emulating them of they are not available. In e.g. dotNet the jitter may have the emulation code available as IL, but when generating code for a machine that provides the extension, it is omitted, along with the test to check the availability - it checked itself before generating the final code.

Code that is fully optimized with all well established methods of today (that includes complete flow analysis) is so good that I cannot see how AI could make any major improvement.
GeneralRe: What about using AI to optimize compiler code generation? Pin
jmaida17-Oct-23 11:59
jmaida17-Oct-23 11:59 
Generalworldle 633 1/6 Pin
jmaida16-Oct-23 16:44
jmaida16-Oct-23 16:44 
GeneralCode telepathy Pin
honey the codewitch16-Oct-23 15:53
mvahoney the codewitch16-Oct-23 15:53 
GeneralRe: Code telepathy Pin
David O'Neil16-Oct-23 16:56
professionalDavid O'Neil16-Oct-23 16:56 
GeneralRe: Code telepathy Pin
honey the codewitch16-Oct-23 17:16
mvahoney the codewitch16-Oct-23 17:16 
GeneralRe: Code telepathy Pin
jmaida16-Oct-23 17:06
jmaida16-Oct-23 17:06 
GeneralRe: Code telepathy Pin
honey the codewitch16-Oct-23 17:13
mvahoney the codewitch16-Oct-23 17:13 
GeneralRe: Code telepathy Pin
jmaida16-Oct-23 19:00
jmaida16-Oct-23 19:00 
GeneralRe: Code telepathy Pin
englebart18-Oct-23 2:20
professionalenglebart18-Oct-23 2:20 
GeneralWordle 850 Pin
StarNamer@work16-Oct-23 13:05
professionalStarNamer@work16-Oct-23 13:05 
GeneralRe: Wordle 850 Pin
Amarnath S16-Oct-23 14:27
professionalAmarnath S16-Oct-23 14:27 
GeneralRe: Wordle 850 Pin
GKP199216-Oct-23 18:14
professionalGKP199216-Oct-23 18:14 
GeneralRe: Wordle 850 Pin
Shane010316-Oct-23 18:44
Shane010316-Oct-23 18:44 
GeneralRe: Wordle 850 Pin
GuyThiebaut16-Oct-23 19:30
professionalGuyThiebaut16-Oct-23 19:30 
GeneralRe: Wordle 850 Pin
Sandeep Mewara16-Oct-23 20:13
mveSandeep Mewara16-Oct-23 20:13 
GeneralRe: Wordle 850 Pin
OriginalGriff16-Oct-23 20:31
mveOriginalGriff16-Oct-23 20:31 
GeneralRe: Wordle 850 - 4 4 me Pin
pkfox16-Oct-23 20:57
professionalpkfox16-Oct-23 20:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.