Implement Vector{Size}.AllBitsSet by Gnbrkm41 · Pull Request #33924 · dotnet/runtime (original) (raw)

The ValueNumber & CSE phase only uses the table to determine if the result type needs to be an input when generating the ValueNumber for the node.

If for two trees that have the same operation (i.e. GT_MUL or the same HW intrinsic) and all of its operands have the identical value numbers, then normally we would give the same value number.

For GT_CAST we incorporate the castto type as an extra operand to the value number.

I noticed that we also needed to do this for some SIMD and HW instrinsic nodes.
I determined that safest and easiest way to to do this was to examine the table of instructions and always incorporate the result type when there were two or more different valid instructions listed for a SIMD or HW instrinsic node.

This process is used for x86 and x64, I believe that we need to be more conservative on ARM64, so we always include an extra result type operand.

As as long as the table has two or more different instructions we will be good.
It would be bad to list all the same instructions or an illegal instruction and then use hand code logic to decide on the instruction. If you want to record that an entry relies upon hand coded logic I would recommend using a brkpt or nop instruction as a marker for this behavior in the table. We can add a check for this and assume that different instructions could be generated. I don't think that it should matter if AVX is supported or not when deciding if we need an extra result type operand.