This is an archive of the discontinued LLVM Phabricator instance.

[LoongArch] Check msb is not less than lsb for the bstr{ins/pick}.{w/d} instructions
ClosedPublic

Authored by SixWeining on May 2 2022, 11:37 PM.

Diff Detail

Event Timeline

SixWeining created this revision.May 2 2022, 11:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 2 2022, 11:37 PM
SixWeining requested review of this revision.May 2 2022, 11:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 2 2022, 11:37 PM
xry111 added a comment.May 3 2022, 3:48 AM

It seems the CI failed with some tests TIMEOUT. Maybe we need to adjust the test timeout for the CI.

LoongArch ISA reference manual has not specified the behavior of bstrins/bstrpick with msb < lsb. Should the manual be updated too?

xry111 added a comment.May 3 2022, 5:33 AM

It seems the CI failed with some tests TIMEOUT. Maybe we need to adjust the test timeout for the CI.

CI passed after I re-ran it.

It seems the CI failed with some tests TIMEOUT. Maybe we need to adjust the test timeout for the CI.

LoongArch ISA reference manual has not specified the behavior of bstrins/bstrpick with msb < lsb. Should the manual be updated too?

Right, the manual doesn’t specify it explicitly. But I think it’s an obvious implication by the instruction explanation. For example:
BSTRINS.W:

bstr32[31:msbw+1] = GR[rd][31: msbw+1]
bstr32[msbw:lsbw] = GR[rj][msbw-lsbw:0]
bstr32[lsbw-1:0] = GR[rd][lsbw-1:0]
GR[rd] = SignExtend(bstr32[31:0], GRLEN)

And this check is also done by GNU as.

Yes, I think it’s better to document it in somewhere.

It seems the CI failed with some tests TIMEOUT. Maybe we need to adjust the test timeout for the CI.

CI passed after I re-ran it.

Thanks.

A polite ping. Thanks.

@xry111 About the ISA document, I will recommend and push the right person to update. But that may not be too fast.

Good to me, but as I've only contributed an one-line change to LLVM let's to wait for someone else :).

MaskRay accepted this revision.May 10 2022, 10:19 AM
MaskRay added inline comments.
llvm/test/MC/LoongArch/Basic/Integer/invalid.s
190

Perhaps pick a different set as 1 < 2 has been covered by the previous instruction.

llvm/test/MC/LoongArch/Basic/Integer/invalid64.s
74

ditto

This revision is now accepted and ready to land.May 10 2022, 10:19 AM

Address @MaskRay's comment. Thanks.

SixWeining marked 2 inline comments as done.May 10 2022, 6:58 PM

Thanks, I have updated the patch.

xen0n accepted this revision.May 10 2022, 8:14 PM

LGTM, thanks!

This revision was landed with ongoing or failed builds.May 11 2022, 6:38 PM
This revision was automatically updated to reflect the committed changes.