Dominik Montada via llvm-dev
2020-Dec-15 15:09 UTC
[llvm-dev] [GlobalISel] Prioritizing long patterns in combiner over short ones
Hi, I'm currently writing target specific combiners with GlobalISel. I have a case where a sub-node of a larger pattern also matches another, smaller combiner pattern. Because the combiner runs top-down, the smaller pattern is matched before the larger pattern has a chance to be matched. Do I have to teach my larger pattern to handle this case or is there a better way to do this? More importantly, are there any plans to improve this behavior? Cheers, Dominik -- ---------------------------------------------------------------------- Dominik Montada Email: dominik.montada at hightec-rt.com HighTec EDV-Systeme GmbH Phone: +49 681 92613 19 Europaallee 19 Fax: +49-681-92613-26 D-66113 Saarbrücken WWW: http://www.hightec-rt.com Managing Director: Vera Strothmann Register Court: Saarbrücken, HRB 10445, VAT ID: DE 138344222 This e-mail may contain confidential and/or privileged information. If you are not the intended recipient please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden. --- -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 6822 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201215/cd13213e/attachment.bin>
Jason Eckhardt via llvm-dev
2020-Dec-15 16:05 UTC
[llvm-dev] [GlobalISel] Prioritizing long patterns in combiner over short ones
GICombineGroup may be of use: // A group of combine rules that can be added to a GICombiner or another group. class GICombineGroup<list<GICombine> rules> : GICombine { // The rules contained in this group. The rules in a group are flattened into // a single list and sorted into whatever order is most efficient. However, // they will never be re-ordered such that behaviour differs from the // specified order. It is therefore possible to use the order of rules in this // list to describe priorities. let Rules = rules; } ________________________________ From: llvm-dev <llvm-dev-bounces at lists.llvm.org> on behalf of Dominik Montada via llvm-dev <llvm-dev at lists.llvm.org> Sent: Tuesday, December 15, 2020 9:09 AM To: LLVM Developers' List <llvm-dev at lists.llvm.org> Subject: [llvm-dev] [GlobalISel] Prioritizing long patterns in combiner over short ones External email: Use caution opening links or attachments Hi, I'm currently writing target specific combiners with GlobalISel. I have a case where a sub-node of a larger pattern also matches another, smaller combiner pattern. Because the combiner runs top-down, the smaller pattern is matched before the larger pattern has a chance to be matched. Do I have to teach my larger pattern to handle this case or is there a better way to do this? More importantly, are there any plans to improve this behavior? Cheers, Dominik -- ---------------------------------------------------------------------- Dominik Montada Email: dominik.montada at hightec-rt.com HighTec EDV-Systeme GmbH Phone: +49 681 92613 19 Europaallee 19 Fax: +49-681-92613-26 D-66113 Saarbrücken WWW: http://www.hightec-rt.com Managing Director: Vera Strothmann Register Court: Saarbrücken, HRB 10445, VAT ID: DE 138344222 This e-mail may contain confidential and/or privileged information. If you are not the intended recipient please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden. --- -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201215/1fa2770e/attachment.html>
Jay Foad via llvm-dev
2020-Dec-17 10:14 UTC
[llvm-dev] [GlobalISel] Prioritizing long patterns in combiner over short ones
I am really surprised that "the combiner runs top-down". Surely it's better to combine smaller sub-expressions before combining larger expressions? Or is there actually a good reason to keep the top-down order?? DAGCombiner also runs mostly top-down (but it can also add nodes to the worklist in a bottom-up direction for certain cases). The top-down order causes problems when you have deep expressions trees that could be simplified away to nothing. Outer combines see these subexpression unsimplified. They can use recursive helper functions like computeKnownBits to try to analyse the unsimplified expression, but the recursive helper functions typically have a max recursion depth of 6. which is easy to hit. DAGCombiner is so embedded now that it is hard to change the basic top-down order, but I would hope we could change the GlobalISel combiner. Jay. On Tue, 15 Dec 2020 at 15:09, Dominik Montada via llvm-dev <llvm-dev at lists.llvm.org> wrote:> > Hi, > > I'm currently writing target specific combiners with GlobalISel. I have > a case where a sub-node of a larger pattern also matches another, > smaller combiner pattern. Because the combiner runs top-down, the > smaller pattern is matched before the larger pattern has a chance to be > matched. Do I have to teach my larger pattern to handle this case or is > there a better way to do this? > > More importantly, are there any plans to improve this behavior? > > Cheers, > > Dominik > > -- > ---------------------------------------------------------------------- > Dominik Montada Email: dominik.montada at hightec-rt.com > HighTec EDV-Systeme GmbH Phone: +49 681 92613 19 > Europaallee 19 Fax: +49-681-92613-26 > D-66113 Saarbrücken WWW: http://www.hightec-rt.com > > Managing Director: Vera Strothmann > Register Court: Saarbrücken, HRB 10445, VAT ID: DE 138344222 > > This e-mail may contain confidential and/or privileged information. If > you are not the intended recipient please notify the sender immediately > and destroy this e-mail. Any unauthorised copying, disclosure or > distribution of the material in this e-mail is strictly forbidden. > --- > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Amara Emerson via llvm-dev
2021-Jan-20 06:51 UTC
[llvm-dev] [GlobalISel] Prioritizing long patterns in combiner over short ones
+Daniel. Daniel, do you remember if there was a strong reason for choosing to go top-down on the combiner? Amara> On Dec 17, 2020, at 2:14 AM, Jay Foad via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > I am really surprised that "the combiner runs top-down". Surely it's > better to combine smaller sub-expressions before combining larger > expressions? Or is there actually a good reason to keep the top-down > order?? > > DAGCombiner also runs mostly top-down (but it can also add nodes to > the worklist in a bottom-up direction for certain cases). The top-down > order causes problems when you have deep expressions trees that could > be simplified away to nothing. Outer combines see these subexpression > unsimplified. They can use recursive helper functions like > computeKnownBits to try to analyse the unsimplified expression, but > the recursive helper functions typically have a max recursion depth of > 6. which is easy to hit. > > DAGCombiner is so embedded now that it is hard to change the basic > top-down order, but I would hope we could change the GlobalISel > combiner. > > Jay. > > On Tue, 15 Dec 2020 at 15:09, Dominik Montada via llvm-dev > <llvm-dev at lists.llvm.org> wrote: >> >> Hi, >> >> I'm currently writing target specific combiners with GlobalISel. I have >> a case where a sub-node of a larger pattern also matches another, >> smaller combiner pattern. Because the combiner runs top-down, the >> smaller pattern is matched before the larger pattern has a chance to be >> matched. Do I have to teach my larger pattern to handle this case or is >> there a better way to do this? >> >> More importantly, are there any plans to improve this behavior? >> >> Cheers, >> >> Dominik >> >> -- >> ---------------------------------------------------------------------- >> Dominik Montada Email: dominik.montada at hightec-rt.com >> HighTec EDV-Systeme GmbH Phone: +49 681 92613 19 >> Europaallee 19 Fax: +49-681-92613-26 >> D-66113 Saarbrücken WWW: http://www.hightec-rt.com >> >> Managing Director: Vera Strothmann >> Register Court: Saarbrücken, HRB 10445, VAT ID: DE 138344222 >> >> This e-mail may contain confidential and/or privileged information. If >> you are not the intended recipient please notify the sender immediately >> and destroy this e-mail. Any unauthorised copying, disclosure or >> distribution of the material in this e-mail is strictly forbidden. >> --- >> >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev