[CIR][Lowering] Fix inconditional sign extension on vec.cmp op #1747
+25
−2
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.
(Copied from my question on Discord)
I’ve been working on the vector to bit-mask related intrinsics for X86. I’ve been stuck specifically on
X86::BI__builtin_ia32_cvtb2mask128(_mm256_movepi16_mask
) and its variations with different vector/mask sizes.In this case, we perform a vector comparison of
vector<16xi16>
and bitcast the resultingvector<16xi1>
directly into a scalar integer mask (i16).I’m successfully able to lower to cir:
There's an issue arises when lowering this to LLVM, the error message I'm getting is:
By looking at the test cases on the llvm dialect, this is related to the sext / zext instruction.
This is the cir → llvm dialect lowered for the latter:
This is seems to be the cause:
The fix: Added a type check: if the result type does not differ from the expected type, we won't insert a sextOp