alexcrichton transferred Issue #1119:
Currently, when we have an instruction that requires legalizations for several types, and the legalization is the same modulo the types involved, we'll create one legalization for each type, and will bind the source instruction to the type.
It's actually a shame, because the meta crate implements type inference and can do better than this: for instance, if the instruction you're legalizing accepts types in a set S, then it could be able to generate all the legalizations for types in S as one legalization, and not one per type.
We could switch to use the type inference a bit more. One drawback I can think of is that it would make it harder to find which legalizations handle which types. It's still possible to look at the generated source files, though, so that's a minor problem.
For what it's worth, I've already implemented it, since I thought I found a bug in the type inference code (it was just never triggered, and has existed as long as type inference existed in Cranelift). Branch is there and diff of generated code is there.
Last updated: Nov 22 2024 at 16:03 UTC