[llvm] [SandboxVec][DAG] Implement PredIterator (PR #111604)
Sriraman Tallam via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 10 11:05:42 PDT 2024
================
@@ -8,10 +8,45 @@
#include "llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h"
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/SandboxIR/Instruction.h"
#include "llvm/SandboxIR/Utils.h"
namespace llvm::sandboxir {
+PredIterator::value_type PredIterator::operator*() {
+ // If it's a DGNode, or a MemDGNode with an OpIt != end.
+ if (!isa<MemDGNode>(N) || OpIt != OpItE) {
+ assert(OpIt != OpItE && "Can't dereference end iterator!");
+ Value *OpV = *OpIt;
+ return DAG->getNode(cast<Instruction>(OpV));
+ }
+ // It's a MemDGNode with OpIt == end, so we need to use MemIt.
+ assert(MemIt != cast<MemDGNode>(N)->memPreds().end() &&
+ "Cant' dereference end iterator!");
+ return *MemIt;
----------------
tmsri wrote:
Can you simplify this code a bit for just more readability:
```
if (!isa<MemDGNode>(N)) {
assert (OpIt != OpItE && .....);
return DAG->getNode(cast<Instruction>(*OpIt));
}
if (OpIt != OpItE)
return DAG->getNode(...);
// It's a ....
```
https://github.com/llvm/llvm-project/pull/111604
More information about the llvm-commits
mailing list