[llvm] [TableGen][SubtargetEmitter] Refactor hasReadOfWrite to CodeGenProcModel (PR #92032)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue May 14 13:46:01 PDT 2024


================
@@ -1122,8 +1122,8 @@ void SubtargetEmitter::GenSchedClassTables(const CodeGenProcModel &ProcModel,
       WriterNames.push_back(SchedModels.getSchedWrite(WriteID).Name);
       // If this Write is not referenced by a ReadAdvance, don't distinguish it
       // from other WriteLatency entries.
-      if (!SchedModels.hasReadOfWrite(
-              SchedModels.getSchedWrite(WriteID).TheDef)) {
+      if (!SchedModels.hasReadOfWrite(SchedModels.getSchedWrite(WriteID).TheDef,
+                                      ProcModel)) {
----------------
topperc wrote:

After reviewing the code, I think if it did change the output everything would still work. For each Write for each ProcModel we are creating a vector of MCWriteLatencyEntry objects. Then we search a large vector to if that sequence of MCWriteLatencyEntry already exists in somewhere in `SchedTables.WriteLatencies`. If we find the sequence we save its index. If we don't find it, we append the vector we have to the end of `SchedTables.WriteLatencies` and save the index where it was appended. The index is used to find the sequence later at runtime.

In the usual case we probably find the sequence once we've created it for the first ProcModel. I think at worst, this patch would make us not find it for some ProcModel and cause it to be added at the end. I don't think would be a functional issue. It would just make `SchedTables.WriteLatencies` larger.

https://github.com/llvm/llvm-project/pull/92032


More information about the llvm-commits mailing list