Fix a couple commutative flags to be correct #106332
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A reddit post (https://www.reddit.com/r/csharp/comments/1equjfd/low_level_things_that_make_me_sad_volume_1/) was made that indicated
Bmi2.MultiplyNoFlags
may not be commutative, so I took a look.The issue the reddit post raises was not due to a missing flag to indicate the intrinsic could be commutative. Rather, its due to LSRA not understanding commutativity itself and therefore there being no way for us to say that "either op1 or op2 must be
RDX
, but which specifically it is doesn't matter". We have a few similar cases where LSRA cannot be accurately told about various preferencing details, such as it being possible for either operand to be contained or reg-optional (just not both simultaneously). So the actual issue comes down to https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/lsraxarch.cpp#L2346-L2347 where we sayop1
must beSRBM_EDX
, which we do becauseop2
is the "containable" operand (as that best fits in with the existing general support for op2 being the operand we want to contain).However, as part of looking at this I audited the flags and found a couple places that were invalid and this PR fixes them. It also normalizes the
NI_BMI2_MultiplyNoFlags
containment support to actually use the main commutative path to ensure other JIT lightup does work as expected for it.