[llvm-dev] Single use rule for chained node in pattern matcher

Krzysztof Parzyszek via llvm-dev llvm-dev at lists.llvm.org
Mon Oct 19 08:53:44 PDT 2020


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


More information about the llvm-dev mailing list