Commit 694f7e8
authored
Update effects for acquire and release operations (#8399)
One of the primary use cases of `EffectAnalyzer` is to determine whether
one expression (or a sequence of expressions) can be reordered before or
after another expression (or sequence of expressions). Until now, the
check whether effects "invalidate" each other and would prevent
reordering has been symmetrical, checking read-write, write-write, and
write-read conflicts as well as symmetric conditions that would prevent
reordering. But acquire load and release store operations break this
symmetry.
Consider an expression A containing an acquire load (and no other
effects) and an expression B containing a release store (and no other
effects), where we know the accesses do not alias. Then if A is before
B, it is not valid to reorder the expressions to have B before A because
the acquire load cannot move forward past the release store and the
release store cannot move back past the acquire load. However, if B is
before A, it _is_ valid to reorder them, since memory accesses are
generally allowed to move forward past acquire loads and back past
release stores.
Update `EffectAnalyzer` to take these allowed reorderings into account
by tracking the strictest memory orders used to read or write to shared
locations in the analyzed expressions.
Now that the effect comparison to see whether reordering is prevented is
no longer symmetric, rename it from `invalidates` to the more
descriptive `orderedBefore`, where `A.orderedBefore(B)` returns true iff
`A` ocurring before `B` implies that there is an ordering constraint
that would prevent reordering `A` and `B` past each other. To accomodate
users trying to move expressions in either direction, also add an
`A.orderedAfter(B)` method for the case where `A` occurs after `B`.
To avoid having to update all users at once, keep an `invalidates`
method that checks for ordering in either direction. This maintains the
symmetry many users depend on. For now, update only SimplifyLocals to
use the more precise directional methods. Add tests both for all the
interesting combinations of atomic effect ordering and for the correct
use of directionality in SimplifyLocals.1 parent 1ed55c3 commit 694f7e8
File tree
6 files changed
+1066
-192
lines changed- src
- ir
- passes
- test
- example
- lit/passes
6 files changed
+1066
-192
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
48 | 54 | | |
49 | 55 | | |
50 | 56 | | |
| |||
57 | 63 | | |
58 | 64 | | |
59 | 65 | | |
60 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
61 | 73 | | |
62 | 74 | | |
63 | 75 | | |
64 | 76 | | |
65 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
66 | 84 | | |
67 | 85 | | |
68 | 86 | | |
69 | 87 | | |
70 | 88 | | |
71 | 89 | | |
72 | | - | |
73 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
74 | 95 | | |
75 | 96 | | |
76 | 97 | | |
| |||
0 commit comments