Open XiaohongGong opened 4 years ago
Yes this is a known limitation. It was never really intended to be fully equivalent to C2's adlc as that seems like engineering overkill given our limited goals for matching. The efficiency of the matching becomes more critical the more patterns that might be matched as well. Would a more definitive match order based on the number of nodes matched be sufficient? Or it could force you to reorder them if an earlier match might hide a later match.
Would a more definitive match order based on the number of nodes matched be sufficient?
Thanks for your additional explanation for it! And I think it's sufficient to add the nodes number dependency for the case I mentioned above.
Thanks, Xiaohong
I'll see what I can do. The real power of the adlc approach comes from the fact that it produces an optimal cover for a DAG that requires multiple machine nodes. So if the DAG can be matched using 2 nodes or 3 nodes, it can efficiently pick the optimal answer based on the total cost of those nodes. But that assumes your costs actually make sense.
I'll see what I can do.
Sorry for the late replying! It's great that it's in your plan. I'm looking forward to it. Thank you so much!
Feature request
Please include the following information:
Is your feature request related to a problem? Please describe. As we all know, a original code pattern can be optimized to multiply patterns. For example:
can be optimized to:
It also has a better optimization pattern:
Obviously the second pattern is better than the first one.
However, currently graal can only match a single rule for the original codes. If a rule is matched, it breaks and continue the next step. The optimized result is greatly decided by the definition order of the match rules.
Assume that the compiler has the following two rules:
If the first rule is matched before the second one, the final optimized instructions will be:
And if the second rule is matched firstly, the final instruction is:
This is not convenient. And sometimes we need to adjust the match rules order to make sure the expected rule is matched.
Describe the solution you'd like. A better solution is to add the comparing rules (instruction costs or something else) for all the match rules that can be matched, and choose the optimal one finally.
Describe who do you think will benefit the most. All the users and contributors can benefit from it.
Describe alternatives you've considered. Maybe graal can get the match rule solution in C2 compiler as a reference.
Additional context. Add any other context about the feature request here. For example, link to the relevant projects, documentation, standards.
Express whether you'd like to help contributing this feature If you'd like to contribute, please read the contribution guide.