Thomas Preud'homme via llvm-dev
2020-Oct-19 09:39 UTC
[llvm-dev] Single use rule for chained node in pattern matcher
Hi, I'm trying to write a pattern for a truncating strict*floating-point instruction that broadcast the result in the resulting register. However the pattern is not recognized by the pattern matcher because the any_fpround node is used more than once due to the broadcasting. I'm not quite sure I understand the reason behind that single use rule [1] (introduced by commit [2]) but all the uses are within the same pattern, as arguments of the same node even. Is there a way to relax the single use rule to allow uses in the same node? If not, how would you suggest I go about implementing pattern matching for this instruction? [1] https://reviews.llvm.org/source/llvm-github/browse/master/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp$3214-3228 [2] https://reviews.llvm.org/rGf8695c1ee9bb8b18a4e1991591fa92383d427435 Thanks in advance for your help. Best regards, Thomas -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201019/5773871d/attachment.html>
Krzysztof Parzyszek via llvm-dev
2020-Oct-19 15:53 UTC
[llvm-dev] Single use rule for chained node in pattern matcher
Single-use is an easy condition to check, easier than analyzing the consequences of folding a sub-DAG on a case by case basis. In general, chain edges can appear. Consider this case (with arrows being chains): A --> C \ / B The chains are A->C, B->C, assume B has multiple uses, but A and C are single-use. If ABC gets matched to T, B must remain due to the extra uses, and we end up with T having a cyclic chain edges with B. -- Krzysztof Parzyszek mailto:kparzysz at quicinc.com AI tools development From: llvm-dev <llvm-dev-bounces at lists.llvm.org> On Behalf Of Thomas Preud'homme via llvm-dev Sent: Monday, October 19, 2020 4:40 AM To: llvm-dev <llvm-dev at lists.llvm.org> Cc: Chris Lattner <clattner at llvm.org> Subject: [EXT] [llvm-dev] Single use rule for chained node in pattern matcher Hi, I'm trying to write a pattern for a truncating strict*floating-point instruction that broadcast the result in the resulting register. However the pattern is not recognized by the pattern matcher because the any_fpround node is used more than once due to the broadcasting. I'm not quite sure I understand the reason behind that single use rule [1] (introduced by commit [2]) but all the uses are within the same pattern, as arguments of the same node even. Is there a way to relax the single use rule to allow uses in the same node? If not, how would you suggest I go about implementing pattern matching for this instruction? [1] https://reviews.llvm.org/source/llvm-github/browse/master/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp$3214-3228 [2] https://reviews.llvm.org/rGf8695c1ee9bb8b18a4e1991591fa92383d427435 Thanks in advance for your help. Best regards, Thomas
Thomas Preud'homme via llvm-dev
2020-Oct-20 10:08 UTC
[llvm-dev] Single use rule for chained node in pattern matcher
Hi Krzysztof, Thanks for the explanation. How about adding the requirement that not only all those uses are by the same node but also that the node is within the sub-DAG being matched? Best regards, Thomas ________________________________ From: llvm-dev <llvm-dev-bounces at lists.llvm.org> on behalf of Krzysztof Parzyszek via llvm-dev <llvm-dev at lists.llvm.org> Sent: 19 October 2020 16:53 To: llvm-dev at lists.llvm.org <llvm-dev at lists.llvm.org> Subject: Re: [llvm-dev] Single use rule for chained node in pattern matcher Single-use is an easy condition to check, easier than analyzing the consequences of folding a sub-DAG on a case by case basis. In general, chain edges can appear. Consider this case (with arrows being chains): A --> C \ / B The chains are A->C, B->C, assume B has multiple uses, but A and C are single-use. If ABC gets matched to T, B must remain due to the extra uses, and we end up with T having a cyclic chain edges with B. -- Krzysztof Parzyszek mailto:kparzysz at quicinc.com AI tools development From: llvm-dev <llvm-dev-bounces at lists.llvm.org> On Behalf Of Thomas Preud'homme via llvm-dev Sent: Monday, October 19, 2020 4:40 AM To: llvm-dev <llvm-dev at lists.llvm.org> Cc: Chris Lattner <clattner at llvm.org> Subject: [EXT] [llvm-dev] Single use rule for chained node in pattern matcher Hi, I'm trying to write a pattern for a truncating strict*floating-point instruction that broadcast the result in the resulting register. However the pattern is not recognized by the pattern matcher because the any_fpround node is used more than once due to the broadcasting. I'm not quite sure I understand the reason behind that single use rule [1] (introduced by commit [2]) but all the uses are within the same pattern, as arguments of the same node even. Is there a way to relax the single use rule to allow uses in the same node? If not, how would you suggest I go about implementing pattern matching for this instruction? [1] https://reviews.llvm.org/source/llvm-github/browse/master/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp$3214-3228 [2] https://reviews.llvm.org/rGf8695c1ee9bb8b18a4e1991591fa92383d427435 Thanks in advance for your help. Best regards, Thomas _______________________________________________ LLVM Developers mailing list llvm-dev at lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201020/5b09ed0c/attachment-0001.html>