Commit Graph

193 Commits

Author SHA1 Message Date
Vitaly Buka
80b9f07436 [VPlan] Suppress leak in test (#114624)
Probably needs a better fix. #114623
2024-11-01 16:26:59 -07:00
vporpo
083369fd99 [SandboxVec][Legality] Per opcode checks (#114145)
This patch adds more opcode-specific legality checks.
2024-11-01 15:04:03 -07:00
Florian Hahn
edd6b1f4fe [VPlan] Don't leak ScalarHeader BasicBlock in unit tests. 2024-11-01 13:52:58 +00:00
Florian Hahn
659c3699e8 [VPlan] Connect scalar header to VPlan CFG in unit tests.
This ensures the VPIRBasicBlocks are deleted when the VPlan is
destroyed.

Fixes a buildbot failure with ASAN, including
https://lab.llvm.org/buildbot/#/builders/52/builds/3368
2024-11-01 09:47:40 +00:00
Florian Hahn
b021464d35 [VPlan] Introduce scalar loop header in plan, remove VPLiveOut. (#109975)
Update VPlan to include the scalar loop header. This allows retiring
VPLiveOut, as the remaining live-outs can now be handled by adding
operands to the wrapped phis in the scalar loop header.

Note that the current version only includes the scalar loop header, no
other loop blocks and also does not wrap it in a region block.

PR: https://github.com/llvm/llvm-project/pull/109975
2024-10-31 21:36:44 +01:00
vporpo
ca998b071e [SandboxVec][Legality] Check wrap flags (#113975) 2024-10-29 15:37:03 -07:00
vporpo
bf4b31ad54 [SandboxVec][Legality] Check Fastmath flags (#113967) 2024-10-28 15:32:20 -07:00
vporpo
5ea694816b [SandboxVec][Legality] Check opcodes and types (#113741) 2024-10-28 14:05:58 -07:00
Vasileios Porpodas
1540f772c7 Reapply "[SandboxVec][Legality] Reject non-instructions (#113190)"
This reverts commit eb9f4756bc.
2024-10-25 12:55:58 -07:00
Vasileios Porpodas
eb9f4756bc Revert "[SandboxVec][Legality] Reject non-instructions (#113190)"
This reverts commit 6c9bbbc818.
2024-10-25 12:52:31 -07:00
vporpo
6c9bbbc818 [SandboxVec][Legality] Reject non-instructions (#113190) 2024-10-25 12:47:19 -07:00
Florian Hahn
0558fe3bbf [VPlan] Update unit tests to use getVectorLoopRegion (NFC).
Use getVectorLoopRegion to retrieve the vector loop header instead of
relying on getting the successor of the entry block. This makes sure the
code still works correctly as more parts of the skeleton are modeled in
VPlan.
2024-10-24 14:49:09 -07:00
Sterling-Augustine
f1be516223 [SandboxVectorizer] New class to actually collect and manage seeds (#113386)
This relands d91318b643, with test-only
changes to make gcc-10 happy.
2024-10-23 10:26:18 -07:00
Sterling-Augustine
0de8de1b84 [SandboxVectorizer] revert New class to actually collect and manage s… (#113231)
…eeds (#112979)

This reverts commit d91318b643.
2024-10-21 16:00:35 -07:00
Sterling-Augustine
d91318b643 [SandboxVectorizer] New class to actually collect and manage seeds (#112979)
There are many more tests to add, but I would like to get this reviewed
and the details sorted out before it grows too big.
2024-10-21 15:39:51 -07:00
vporpo
54c93aabec [SandboxVec][Legality] Scaffolding for Legality (#112623)
This patch adds a LegalityResultWithReason class for describing the
reason why legality decided not to vectorize the code.
2024-10-21 09:17:46 -07: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
Florian Hahn
b497010854 [VPlan] Use VPInstruction::Name when assigning names (NFCI).
This slightly improves the printing of VPInstructions. NFC except debug
output.
2024-10-18 05:52:35 +01:00
Florian Hahn
81bbe19383 [VPlan] Add VPSingleDefRecipe::dump() to resolve ambigous lookup (NFC).
This allows calling ::dump() on various sub-classes of VPSingleDefRecipe
directly, as it resolves an ambigous name lookup.

Previously, calling VPWidenRecipe::dump() (and others), would result in

the following errors:
llvm/unittests/Transforms/Vectorize/VPlanTest.cpp:1284:19: error: member 'dump' found in multiple base classes of different types
 1284 |           WidenR->dump();
      |                   ^
llvm/include/../lib/Transforms/Vectorize/VPlanValue.h:434:8: note: member found by ambiguous name lookup
  434 |   void dump() const;
      |        ^
llvm/include/../lib/Transforms/Vectorize/VPlanValue.h:108:8: note: member found by ambiguous name lookup
  108 |   void dump() const;
      |        ^
1 error generated.
2024-10-17 05:31:29 +01:00
Sterling-Augustine
b26c514b2c [SandboxVectorizer] Add container class to track and manage SeedBundles (#112048) 2024-10-14 16:36:05 -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
31b85c6ead [SandboxVec][Interval] Implement Interval::comesBefore() (#112026)
This patch implements `Interval::comesBefore(const Interval &Other)`
which returns true if this interval is strictly before Other in program
order. The function asserts that the intervals are disjoint.
2024-10-11 11:51:38 -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
Rahul Joshi
fa789dffb1 [NFC] Rename Intrinsic::getDeclaration to getOrInsertDeclaration (#111752)
Rename the function to reflect its correct behavior and to be consistent
with `Module::getOrInsertFunction`. This is also in preparation of
adding a new `Intrinsic::getDeclaration` that will have behavior similar
to `Module::getFunction` (i.e, just lookup, no creation).
2024-10-11 05:26:03 -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
Sterling-Augustine
e5fae7682d [SandboxVectorizer] Add MemSeed bundle types (#111584) 2024-10-08 15:38:07 -07:00
Florian Hahn
6fbbe152fa [VPlan] Introduce VPWidenIntrinsicRecipe to separate from libcall. (#110486)
This patch splits off intrinsic hanlding to a new
VPWidenIntrinsicRecipe. VPWidenIntrinsicRecipes only need access to the
intrinsic ID to widen and the scalar result type (in case the intrinsic
is overloaded on the result type). It does not need access to an
underlying IR call instruction or function.

This means VPWidenIntrinsicRecipe can be created easily without access
to underlying IR.
2024-10-08 22:37:20 +01:00
vporpo
3c6041d28c [SandboxVec][Interval] Implement getUnionInterval() and getSingleDiff() (#111455) 2024-10-08 10:57:16 -07:00
Sterling-Augustine
fbb8234ca9 [SandboxIR][NFC] Remove unused include (#111422) 2024-10-07 12:24:42 -07:00
Sterling-Augustine
93bfa7886b [SandboxVectorizer] Define SeedBundle: a set of instructions to be vectorized [retry] (#111073)
[Retry 110696 with a proper rebase.]

Seed collection will assemble instructions to be vectorized into
SeedBundles. This data structure is not intended to be used directly,
but will be the basis for load bundles, store bundles, and so on.
2024-10-07 11:20:50 -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
c214af8454 [SandboxVec][Interval] Implement intersection and difference operations (#110549)
This patch implements a few set operations for the intervals. These
include:
- operator==() and operator!=() for comparing two intervals.
- disjoint()
- intersection()
- difference, which uses operator-()
2024-09-30 15:23:02 -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 8dfeb4ef5d.
2024-09-27 13:18:44 -07:00
Vasileios Porpodas
8dfeb4ef5d Revert "[SandboxIR][NFC] Delete SandboxIR.h (#110309)"
This reverts commit ca47f48a5c.
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
eba106d461 [SandboxIR][NFC] Move Instruction classes into a separate file (#110294) 2024-09-27 10:54:11 -07:00
Jorge Gorbe Moya
9efc761d42 Reapply "[SandboxIR][NFC] Move Region from SandboxVectorizer to SandboxIR." (#110173) (#110181)
Re-applies llvm/llvm-project#110173 after fixing build break.
2024-09-26 18:12:31 -07:00
vporpo
3c66a51054 [SandboxVec][Interval] Convert InstrInterval class to a class template (#110021)
This patch converts InstrInterval class to a class template and renames
InstrInterval to Itnerval.

This change will allow us to reuse the Interval for dependency graph
nodes.
2024-09-26 17:47:25 -07:00
Jorge Gorbe Moya
74f276dd0f Revert "[SandboxIR][NFC] Move Region from SandboxVectorizer to SandboxIR." (#110177)
Reverts llvm/llvm-project#110173. Missed an #include with the old path.
2024-09-26 14:56:19 -07:00
Jorge Gorbe Moya
3d9ed92630 [SandboxIR][NFC] Move Region from SandboxVectorizer to SandboxIR. (#110173)
I'm planning to add RegionPass and RegionPassManager next to the
equivalent FunctionPass and FunctionPassManager in SandboxIR, which
means that SandboxIR has to know about Regions.

There's nothing vectorizer-specific about the Region class, and the only
thing using Regions at this moment is the unit test, so this is a
straightforward file move.
2024-09-26 14:48:28 -07:00
Florian Hahn
68ed1728bf [VPlan] Unify mayWriteToMemory and mayHaveSideEffects logic for VPInst.
Unify logic for mayWriteToMemory and mayHaveSideEffects for
VPInstruction, with the later relying on the former. Also extend to
handle binary operators.

Split off from https://github.com/llvm/llvm-project/pull/106441
2024-09-26 19:16:43 +01:00
Jorge Gorbe Moya
3bb92b530f [SandboxVec] Tag insts in a Region with metadata. (#109353)
For each region, we create a metadata node. Then when an instruction is
added to the Region, it gets tagged with the metadata node for that
region. In the following example, we have a Region that contains only
the `%t0` instruction.

```
define i8 @foo(i8 %v0, i8 %v1) {
  %t0 = add i8 %v0, 1, !sbvec !0
  %t1 = add i8 %t0, %v1
  ret i8 %t1
}

!0 = distinct !{!"region"}
```

This commit also adds a function to create regions from metadata already
present in a Function.

This metadata can be used for debugging: if we dump IR before a Region
pass, the IR will contain enough info to re-create the Region and run
the pass by itself in a later invocation.

---------

Co-authored-by: Alina Sbirlea <alina.g.simion@gmail.com>
2024-09-23 16:59:02 -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
abc2412f07 [SandboxVec][InstrInterval] Add ArrayRef constructor (#109357)
The new constructor creates an InstrInterval from an
ArrayRef<Instruction *>. This patch also adds top() and bottom()
getters.
2024-09-20 16:17:09 -07:00