Quantcast
Channel: What are the ways compilers recognize complex patterns? - Programming Language Design and Implementation Stack Exchange
Browsing latest articles
Browse All 6 View Live

Answer by Alexis King for What are the ways compilers recognize complex...

The boring answer: it really is just hardcodedThe answer to the general question of “how do compilers recognize optimizable patterns?” would be large enough to fill a book. Certainly, there are lots of...

View Article


Answer by Eldritch Conundrum for What are the ways compilers recognize...

As an aside to @kouta-kun's answer for gcc, I searched what llvm does.I found popcnt being generated in LoopIdiomRecognize.cpp, a pass that recognizes idioms and transforms simple loops into a non-loop...

View Article

Answer by kouta-kun for What are the ways compilers recognize complex patterns?

By running gcc -O3 -fdump-tree-all-all main.c -S -march=haswell which prints out all optimization steps, we can find that this optimization is performed in main.c.036t.forwprop1:Pass statistics of...

View Article

What are the ways compilers recognize complex patterns?

This answer is an example of a compiler recognizing that a complex expression is equivalent to a single operation:uint8_t pcnt64(uint64_t n) { n = n - ((n >> 1) & 0x5555555555555555ULL); n =...

View Article

Answer by Moonchild for What are the ways compilers recognize complex patterns?

canonicalisation (c.f. my other answer) is indeed relevant. it is no panacea—we cannot 'reduce any function into some "canonical form"' due to godel, rice, et al, and even for the cases where that is...

View Article


Answer by Kaz for What are the ways compilers recognize complex patterns?

Some compilers use actual complex pattern matching to recognize complex patterns. For instance the optimizer module in TXR Lisp uses pattern matching over the virtual machine instruction sequences.A...

View Article
Browsing latest articles
Browse All 6 View Live