-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[LoongArch64] Fix code generation for type conversion from float/double to uint/ulong. #105783
Conversation
…le to uint/ulong.
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
@shushanhf Could you please review this change? |
If LA64 doesn't have native conversion instruction for fp<->unsigned, are the |
We just use some instructions embedded by the codegen to avoid calling helpers. |
Is there any JIT tests covering this? I can find |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks
@jakobbotsch could you please review this PR?
@jakobbotsch could you please review this PR? |
/azp run runtime |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run runtime-dev-innerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
The previous conversion from floating-point numbers to unsigned integers was incorrect in handling negative numbers and NaN.The previous instructions are as follows:
lu52i.d $r21, $zero, 1086
movgr2fr.d $ft3, $r21
fcmp.clt.d $fcc2, $fs0, $ft3
fcmp.ceq.d $fcc3, $fs0, $ft3
li.w $r21, 0x0
bcnez $fcc2, 16
fsub.d $ft3, $fs0, $ft3
li.w $r21, 0x1
slli.d $r21, $r21, 0x3f
fsel $ft3, $ft3, $fs0, $fcc2
ftintrz.l.d $ft3, $ft3
movfr2gr.d $a0, $ft3
bcnez $fcc3, 8
beqz $a0, 8
or $a0, $r21, $a0
After modification, negative numbers and NaN are handled first.The modified instructions are as follows:
li.w $a0, 0x0
movgr2fr.d $ft3, $zero
fcmp.cult.d $fcc2, $fa0, $ft3
bcnez $fcc2, 52
lu52i.d $r21, $zero, 1086
movgr2fr.d $ft3, $r21
fcmp.clt.d $fcc2, $fa0, $ft3
li.w $r21, 0x0
bcnez $fcc2, 16
fsub.d $ft3, $fa0, $ft3
li.w $r21, 0x1
slli.d $r21, $r21, 0x3f
fsel $ft3, $ft3, $fa0, $fcc2
ftintrz.l.d $ft3, $ft3
movfr2gr.d $a0, $ft3
or $a0, $r21, $a0