[llvm] [SandboxVec][DAG] Build actual dependencies (PR #111094)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 8 08:50:22 PDT 2024
================
@@ -50,29 +51,137 @@ MemDGNodeIntervalBuilder::make(const Interval<Instruction> &Instrs,
cast<MemDGNode>(DAG.getNode(MemBotI)));
}
+DependencyGraph::DependencyType
+DependencyGraph::getRoughDepType(Instruction *FromI, Instruction *ToI) {
+ if (FromI->mayWriteToMemory()) {
+ if (ToI->mayReadFromMemory())
+ return DependencyType::RAW;
+ if (ToI->mayWriteToMemory())
+ return DependencyType::WAW;
+ }
+ if (FromI->mayReadFromMemory()) {
+ if (ToI->mayWriteToMemory())
+ return DependencyType::WAR;
+ if (ToI->mayReadFromMemory())
+ return DependencyType::RAR;
+ }
----------------
vporpo wrote:
> Why not else-if in the second outer if for FromI?
else-if should work. DONE.
> Why is ToI checked first for Read in the first-if and for write in the second, any implicit ordering?
The order matters in the second outer `if` because one of them is a RAR (no dependency) and the other one is a WAR which is a dependency. The order in the first outer `if` shouldn't matter.
> If ToI is not mem read/write this code will still go through all the checks?
Currently yes, we could speed it up perhaps by checking `mayReadOrWriteMemory()` for both and skip some of the code if neither is memory. I will add a TODO for it to do this change after we have enough tests and some benchmarks for the DAG.
> Can it both read and write memory,
Yes
> if so can we make it simpler, something along these lines where write takes precedence?
Yeah, this should also work, but it seems to be doing the same number of checks while being more verbose (because of the enum declaration). I don't feel too strongly about keeping the original one though.
https://github.com/llvm/llvm-project/pull/111094
More information about the llvm-commits
mailing list