Create canonical form for bitfieldInsert. (#2085)
Create canonical form for bitfieldInsert. (#2085)

When translating bitfieldInsert instructions within the ArithBuilder, a form
which later gets picked up by InstCombine will be generated. Unfortunately, this
form does not support bitfieldInsert instructions with one bitfieldInsert
being the base for another bitfieldInsert. The resulting sequence can not be
matched into multiple v_bfi instructions.

By directly generating the canonical form in the ArithBuilder, single v_bfi
instructions will still be generated, but dependent v_bfi instructions with
one being the base for another one end up being simplified by
SimplifyDemandedBits.
However, in such cases, the original inverted bitmask for the outer
bitfieldInsert can be reconstructed, as long as the constants are disjoint and
are a partition of -1. This means, the sequence can be transformed into
multiple v_bfi instructions during ISel.

Co-authored-by: Thomas Symalla <763456fd9b2f78b81ece288bd66208fa96b7dce9@amd.com>
GPUOpen-Drivers/llpc,GPUOpen-Drivers/llpc,GPUOpen-Drivers/llpc,GPUOpen-Drivers/llpc,GPUOpen-Drivers/llpc