Closed Pierre-vh closed 2 months ago
I have two different use-cases: Given a G_EXTRACT_VECTOR_ELT, I want to express in Mir that the source is a G_BUILD_VECTOR.
In https://github.com/llvm/llvm-project/pull/67358, it is the opposite. I want to express that the uses of a G_BUILD_VECTOR are binops.
Should the variadic operand(s) act as "one or more" or "zero or more"? e.g. in the first example above, should a 2-operand BUILD_VECTOR be allowed, or does varargs:$others implies at least 3 operands in total?
I would assume a pattern without mentioning varargs would work for however many operands are listed. I would then expect varargs to be 1 or more
Are there any plans?
G_BUILD_VECTOR $bv
G_TRUNC $root, $bv
A cheap version would be nice to push the truncate through the build vector.
cc @shiltian
Are there any plans?
G_BUILD_VECTOR $bv G_TRUNC $root, $bv
A cheap version would be nice to push the truncate through the build vector.
I haven't looked at this seriously yet, but I have some bandwidth now so I'll try to have a look.
What is the scope of the use cases? Once the varargs are matched, what kind of feature do you (and @arsenm) need to be able to do?
A really cheap first step would be nice to have. I just want to express the pattern truncate(build_vector) in MIR. The rest can be in C++: https://github.com/llvm/llvm-project/blob/430b2545032db9de7898444502915f89e20f7c4c/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp#L15038
In C++, I would then see a G_TRUNC and a G_BUILD_VECTOR. We can use the standard methods for access.
Description
Allow "parameter packs" or similar for MIR patterns to support matching any number of operands. e.g.
G_BUILD_VECTOR
has a variable number of operands, and currently we can only write patterns for a fixed number of operands.Optional goals:
Syntax suggestion
G_BUILD_VECTOR $x, $y, varargs:$others
G_BUILD_VECTOR $x, $y, varargs<2,4>:$others // 2 to 4 operands
Potential issues
varargs:$others
implies at least 3 operands in total?Related
87194