> This is a draft patch. I would like to explain it's hard to make the > simplify generic and ask for some help. > > There're 2 categories we need to optimize. > > - The op in optab such as div / 1. > - The unspec operation such as mulh * 0, (vadc+vmadc) + 0. > > Especially for the unspec operation, I found we need to write one by > one to match the special pattern. Seems there's no way to write a > generic pattern that will match mulh, (vadc+vmadc), sll... This way > is too complicated and not so elegant because need to write so much > md patterns. > > Do you have any ideas?
Yes, it's cumbersome having to add the patterns individually and it would be nicer to have the middle end optimize for us. However, adding new rtl expressions, especially generic ones that are useful for others and the respective optimizations is a tedious process as well. Still, just recently Roger Sayle added bitreverse and copysign. You can refer to his patch as well as the follow-up ones to get an idea of what would need to be done. ("Add RTX codes for BITREVERSE and COPYSIGN") So if we have few patterns that are really performance critical (like for some benchmark) my take is to add them in a similar way you were proposing but I would advise against using this excessively. Is the mulh case somehow common or critical? Regards Robin