34 Commits

Author SHA1 Message Date
vporpo
720615f495
[SandboxVec][DAG] Fix DAG update when user is scheduled (#187148)
This patch fixes the update of the DAGNode UnscheduledSucc counter when
a use edge is modified. This is the result of a setOperand() or a RAUW
(and friends) operation.

Before this patch we would not check if the User (i.e., the consumer of
the use-def edge) is scheduled and we would update the definition's
UnscheduledSucc counter, resulting in counting errors.

For example, consider the following IR:
```
  %A = ...
  %B = ...
  %U = %A  ; scheduled
```
Note that %U's DAGNode is marked as "scheduled" while %A and %B are not.

If we change %U's operand from %A to %B then we should not attempt to
update %A's or %B's UnscheduledSuccs because %U is scheduled so it
should not get counted as an "unscheduled" successor.
2026-03-20 15:43:27 -07:00
vporpo
30db2a73d6
[SandboxVec][DAG][NFC] Remove argument from setScheduelued() (#185787)
DGNode::setScheduled() is only used to mark a nodes a scheduled, not the
reverse. The reverse should only happen with a call to
DGNode::resetScheduleState().
2026-03-11 12:03:57 -07:00
vporpo
482bb3d19a
[SandboxVec][DAG] Mark UnscheduledSuccs as invalid when vectorized (#185519)
When a DAG node gets scheduled, it's UnscheduledSuccs variable becomes
invalid. Up until now we had no way in the code of expressing this.

This patch converts UnscheduledSuccs to an std::optional in order to
protect its use when not valid.
2026-03-10 18:27:52 -07:00
vporpo
e4580d2195
[SandboxVec][DAG] Fix unscheduled succs when nodes are scheduled (#184946)
When we update use-def edges the DAG gets notified to update the
UnscheduledSuccs counters. However, if either edge node is already
scheduled we should not update UnscheduledSuccs because the
UnscheduledSuccs counter value should be treated as "undefined" after a
node has been scheduled, i.e., it's value has a meaning only before the
node gets scheduled.
2026-03-09 08:58:15 -07:00
vporpo
1093a18ba3
[SandboxVec][DAG] Handle unscheduled successors when user is external (#183861)
Whenever an IR use-def edge gets updated, the DAG gets notified about
the change by having its `notifySetUse()` callback called. The
callback's job is to update the DAG node's `UnscheduledSuccs` counter
which is the number of successor nodes that are yet to be scheduled.

This update makes sense only if both ends of the use-def edge are in the
DAG. Up until now we would still update the counter even if the user was
outside the DAG. This patch fixes this, so from now on we skip updatinge
`UnscheduledSuccs` if the user is outside the DAG.
2026-03-05 20:43:09 -08:00
Matt Arsenault
c91cbafad2
TargetLibraryInfo: Delete default TargetLibraryInfoImpl constructor (#145826)
It should not be possible to construct one without a triple. It would
also be nice to delete TargetLibraryInfoWrapperPass, but that is more
difficult.
2025-06-26 16:12:36 +09:00
vporpo
426148b269
[SandboxVec][DAG] Implement DAG maintainance on Instruction removal (#127361)
This patch implements dependency maintenance upon receiveing the
notification that an instruction gets deleted.
2025-02-18 10:59:31 -08:00
vporpo
3e3af861b4
[SandboxVec][DAG] Add MemDGNode::MemSuccs (#127253)
This patch adds Memory successors to the memory nodes of the DAG. This
will help maintain the memory dependencies when nodes get removed.
2025-02-15 17:09:51 -08:00
vporpo
48c92dda00
[SandboxVec][DAG] Update DAG whenever a Use is set (#127247)
This patch implements automatic DAG updating whenever a Use is set. This
maintains the UnscheduledSuccs counter that the scheduler relies on.
2025-02-14 11:58:31 -08:00
vporpo
1c207f1b6e
[SandboxVec][DAG] Fix DAG when old interval is mem free (#126983)
This patch fixes a bug in `DependencyGraph::extend()` when the old
interval contains no memory instructions. When this is the case we
should do a full dependency scan of the new interval.
2025-02-12 15:06:30 -08:00
vporpo
166b2e8837
[SandboxVec][DAG] Update DAG when a new instruction is created (#126124)
The DAG will now receive a callback whenever a new instruction is
created and will update itself accordingly.
2025-02-06 14:12:03 -08:00
vporpo
788c88e2f6
[SandboxVec][DependencyGraph] Fix dependency node iterators (#125616)
This patch fixes a bug in the dependency node iterators that would
incorrectly not skip nodes that are not in the current DAG. This
resulted in iterators returning nullptr when dereferenced.

The fix is to update the existing "skip" function to not only skip
non-instruction values but also to skip instructions not in the DAG.
2025-02-06 12:30:49 -08:00
vporpo
b41987beae
[SandboxVec][DAG] Fix MemDGNode chain maintenance when move destination is non-mem (#124227)
This patch fixes a bug in the maintenance of the MemDGNode chain of the
DAG. Whenever we move a memory instruction, the DAG gets notified about
the move and maintains the chain of memory nodes. The bug was that if
the destination of the move was not a memory instruction, then the
memory node's next node would end up pointing to itself.
2025-01-24 13:59:32 -08:00
vporpo
7a38445ee2
[SandboxVec][DAG] Register move instr callback (#120146)
This patch implements the move instruction notifier for the DAG.
Whenever an instruction moves the notifier will maintain the DAG.
2024-12-20 23:10:24 -08:00
vporpo
cafb6b99bb
[SandboxVec][DAG] Update MemDGNode chain upon instr deletion (#118921) 2024-12-10 15:10:45 -08:00
vporpo
eeb55d3af6
[SandboxVec][DAG] Update MemDGNode chain upon instr creation (#116896)
The DAG maintains a chain of MemDGNodes that links together all the
nodes that may touch memroy.
Whenever a new instruction gets created we need to make sure that this
chain gets updated. If the new instruction touches memory then its
corresponding MemDGNode should be inserted into the chain.
2024-12-05 20:23:06 -08:00
vporpo
6e4821487f
[SandboxVec][DAG] Register callback for erase instr (#116742)
This patch adds the callback registration logic in the DAG's constructor
and the corresponding deregistration logic in the destructor. It also
implements the code that makes sure that SchedBundle and DGNodes can be
safely destroyed in any order.
2024-11-19 16:20:38 -08:00
vporpo
31a4d2c2eb
[SandboxVec][DAG] Cleanup: Move callback registration from Scheduler to DAG (#116455)
This is a refactoring patch that moves the callback registration for
getting notified about new instructions from the scheduler to the DAG.
This makes sense from a design and testing point of view:
- the DAG should not rely on the scheduler for getting notified
- the notifiers don't need to be public
- it's easier to test the notifiers directly from within the DAG unit
tests
2024-11-18 20:23:10 -08:00
vporpo
1d09925b4a
[SandboxVec][Scheduler] Boilerplate and initial implementation. (#112449)
This patch implements a ready-list-based scheduler that operates on
DependencyGraph.
It is used by the sandbox vectorizer to test the legality of vectorizing
a group of instrs.

SchedBundle is a helper container, containing all DGNodes that
correspond to the instructions that we are attempting to schedule with
trySchedule(Instrs).
2024-10-18 16:18:43 -07:00
vporpo
fc08ad6610
[SandboxVec][DAG] Implement UnscheduledSuccs (#112255)
This patch implements the UnscheduledSuccs counter in DGNode. It counts
the number of unscheduled successors and is used by the scheduler to
determine when a node is ready.
2024-10-14 16:23:22 -07:00
vporpo
e8dd95e97b
[SandboxVec][DAG] Extend DAG (#111908)
This patch implements growing the DAG towards the top or bottom. This
does the necessary dependency checks and adds new mem dependencies.
2024-10-11 08:12:29 -07:00
vporpo
69c0067927
[SandboxVec][DAG] Refactoring: Outline code that looks for mem nodes (#111750) 2024-10-10 13:25:03 -07:00
vporpo
a4916d2005
[SandboxVec][DAG] Refactoring: Move MemPreds from DGNode to MemDGNode (#111897) 2024-10-10 12:42:28 -07:00
vporpo
747d8f3fc9
[SandboxVec][DAG] Implement PredIterator (#111604)
This patch implements an iterator for iterating over both use-def and
mem dependencies of MemDGNodes.
2024-10-10 12:01:56 -07:00
vporpo
04a8bffdf7
[SandboxVec][DAG] Build actual dependencies (#111094)
This patch implements actual dependencies checking using BatchAA. This
adds memory dep edges between MemDGNodes.
2024-10-08 16:18:57 -07:00
vporpo
7b9c6a7c3c
[SandboxVec][DAG][NFC] Move functions from Utils to DependencyGraph (#111031)
This patch moves:
- Utils::isStackSaveOrRestoreIntrinsic()
- Utils::isMemIntrinsic()
- Utils::isMemDepCandidate()

to DGNode because they no longer require LLVM IR access and are used
only by the DAG.
2024-10-03 15:28:08 -07:00
vporpo
fd5e220fa6
[SandboxVec][DAG] MemDGNode for memory-dependency candidate nodes (#109684)
This patch implements the MemDGNode class for DAG nodes that are
candidates
for memory dependencies. These nodes form a chain that is accessible by
`getPrevNode()` and `getNextNode()`.

It also implements a builder class that creates MemDGNode intervals from
Instructions.
2024-10-01 15:40:54 -07:00
vporpo
e22b07e766
[SandboxIR][NFC] Move Function class to a separate file (#110526) 2024-09-30 10:12:47 -07:00
Vasileios Porpodas
2018f4ccf2 Reapply "[SandboxIR][NFC] Delete SandboxIR.h (#110309)"
This reverts commit 8dfeb4ef5d60a5c764f0ce249cc4ec69e012ff93.
2024-09-27 13:18:44 -07:00
Vasileios Porpodas
8dfeb4ef5d Revert "[SandboxIR][NFC] Delete SandboxIR.h (#110309)"
This reverts commit ca47f48a5c9e81ef8b5c4a5b1fbc473ea5d5497c.
2024-09-27 12:53:25 -07:00
vporpo
ca47f48a5c
[SandboxIR][NFC] Delete SandboxIR.h (#110309) 2024-09-27 12:20:08 -07:00
vporpo
8f31ee996a
[SandboxVec][DAG] Implement DGNode::isMem() (#109504)
DGNode::isMem() returns true if the node is a memory dependency
candidate.
2024-09-21 08:09:30 -07:00
vporpo
0c9f7ef527
[SandboxVec][DAG] Implement extend(ArrayRef) (#109493)
This builds the DAG from an ArrayRef of Instructions.
2024-09-20 19:09:00 -07:00
vporpo
318d2f5e5d
[SandboxVec][DAG] Boilerplate (#108862)
This patch adds a very basic implementation of the Dependency Graph to
be used by the vectorizer.
2024-09-17 12:03:52 -07:00