This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Verify SEW/VecPolicy immediate values
ClosedPublic

Authored by reames on Sep 14 2022, 8:48 AM.

Details

Summary

Copy the asserts from the printing code, and turn them into actual verifier rules. Doing this revealed an existing bug - see D133868.

Diff Detail

Event Timeline

reames created this revision.Sep 14 2022, 8:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 14 2022, 8:48 AM
reames requested review of this revision.Sep 14 2022, 8:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 14 2022, 8:48 AM
asb added a comment.Sep 14 2022, 12:31 PM

@reames what's your thinking about the current asserts in the printing code - to keep them, or not?

I think it definitely makes sense to add these verifier rules and the code seems like an accurate translation from the printing code to my eyes. I'd appreciate if someone else a little more familiar with the vector instructions would give a quick additional review, but otherwise LGTM.

craig.topper added inline comments.Sep 14 2022, 12:52 PM
llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
1224

MI.getDesc() here should be the same as Desc 2 lines up. But it looks like we took the long way to create Desc at the top of this function.

@reames what's your thinking about the current asserts in the printing code - to keep them, or not?

Had not planned to remove them. A data point is that the verifier does not use that printing path, so having them doesn't influence verification failures.

llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
1224

Will reuse, update pending.

reames updated this revision to Diff 460195.Sep 14 2022, 1:07 PM
craig.topper added inline comments.Sep 14 2022, 1:14 PM
llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
1225

The immediate operand stores 64 bits, should we check all 64 bits and make sure its small enough to be a shift amount before using it to shift?

1234

Should we check all 64 bits of the immediate?

reames updated this revision to Diff 460217.Sep 14 2022, 2:02 PM
This revision is now accepted and ready to land.Sep 14 2022, 2:33 PM
This revision was landed with ongoing or failed builds.Sep 14 2022, 2:46 PM
This revision was automatically updated to reflect the committed changes.