Open MaxGraey opened 2 years ago
This might make sense, yes. It's like monomorphization but that is usually referring to type specialization instead of values like here.
However, inlining will achieve similar results if the called function is small enough, so I'm not sure how much that would help in practice on real-world code.
However, inlining will achieve similar results if the called function is small enough, so I'm not sure how much that would help in practice on real-world code.
Yes, if pow
is relatively small, but it's not a case in most cases. That's btw why this pass better run after inline pass but not as final pass
Currently, DAE pass create only one truncated copy of a function, one of whose arguments are constantly called with the same constant value. This works well for functions with default values. but there is also another class of functions where, for example, the input argument parametrizes the execution strategy and often has fast paths. For example (pseudocode):
For such cases DAE could also work very well if you improve the heuristics and make truncated copies of all constant values that were found in the "if" / "switch / case" conditions. So improved DAE could create truncated 4 specialized copies:
WDYT?