This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Fold prepass back into InsertVSETVLI data flow [nfc-ish]
ClosedPublic

Authored by reames on Jun 15 2022, 9:08 AM.

Details

Summary

When working through correctness issues in this pass, I moved a number of transforms which were phrased as mutating prior vsetvli instructions out of the main data flow because mutating prior instructions can invalidate the running dataflow results in subtle ways. We ended up creating both a prepass and a post-pass.

After consideration, I believe the prepass to be redundant, and this change removes it by folding it back into the data flow via a key conceptual change. Instead of phrasing the mutations on instructions, we can phrase them on abstract states. This avoids the dataflow inconsistency problem mentioned above by simply propagating the potential change forward, and thus reflecting its results in the dataflow.

Compile time wise, this removes a linear pass, but has the potential to increase the number of iterations for the data flow to converge. That's not a algorithmic complexity change, the needVSETVLI mechanism has the same effect. In practice, I don't see this triggering more iterations, so I think it's likely to be a net win overall. (I didn't do any careful analysis here; just an impression from glancing at a couple tests.)

This has the potential to produce better results, but the test changes are pretty minimal. The one change here is the result of the prepass not using needVSETVLI. It could easily have been extended with that, so the sole difference is pretty unconvincing.

Diff Detail

Event Timeline

reames created this revision.Jun 15 2022, 9:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 15 2022, 9:08 AM
reames requested review of this revision.Jun 15 2022, 9:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 15 2022, 9:08 AM
reames updated this revision to Diff 437207.Jun 15 2022, 9:13 AM

Reduce nesting further by moving an early return.

craig.topper accepted this revision.Jun 15 2022, 4:51 PM

LGTM

llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
1074

possible -> possibly?

This revision is now accepted and ready to land.Jun 15 2022, 4:51 PM
This revision was landed with ongoing or failed builds.Jun 20 2022, 7:56 AM
This revision was automatically updated to reflect the committed changes.