This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Fix a latent miscompile in doPeepholeMaskedRVV
ClosedPublic

Authored by reames on Jun 15 2023, 1:24 PM.

Details

Summary

The code was using the tail policy being "agnostic" to select a instruction whose semantics were "undefined". This was almost always fine (as the pass through operand was usually implicit_def), but could in theory lead to a miscompile. I don't actually have a test case as it requires a later transform to exploit the wrong tail policy state, and I couldn't easily figure out to get vsetvli insertion to miscompile given the wrong state. This was spotted by inspection, and it may be a miscompile in theory only at the moment.

Note that this may cause regressions if there are instructions for which we either don't have a _TU pseudo form, or the _TU pseudo form is missing a policy operand. When I was first looking at this, I saw exactly that, and D153067 exists to add the missing policy operand I noticed.

As a later follow up, I want to always force the use of _TU, but it seemed good to fix the bug, then driven the _TU transition in a separate patch.

Diff Detail

Event Timeline

reames created this revision.Jun 15 2023, 1:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 15 2023, 1:24 PM
reames requested review of this revision.Jun 15 2023, 1:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 15 2023, 1:24 PM
This revision is now accepted and ready to land.Jun 16 2023, 2:40 PM
This revision was landed with ongoing or failed builds.Jun 16 2023, 4:53 PM
This revision was automatically updated to reflect the committed changes.