Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
Hercules
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
llvm
Hercules
Merge requests
!129
Possible fix for reduce cycles
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Possible fix for reduce cycles
fix_reduce_cycles
into
main
Overview
0
Commits
1
Pipelines
1
Changes
2
Merged
rarbore2
requested to merge
fix_reduce_cycles
into
main
2 months ago
Overview
0
Commits
1
Pipelines
1
Changes
2
Expand
Don't go through phis outside of a fork join when calculating reduce cycles.
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
f1fe4697
1 commit,
2 months ago
2 files
+
27
−
4
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
hercules_ir/src/loops.rs
+
15
−
2
Options
@@ -233,14 +233,21 @@ fn loop_reachability_helper(
pub
fn
reduce_cycles
(
function
:
&
Function
,
def_use
:
&
ImmutableDefUseMap
,
fork_join_map
:
&
HashMap
<
NodeID
,
NodeID
>
,
fork_join_nest
:
&
HashMap
<
NodeID
,
Vec
<
NodeID
>>
,
)
->
HashMap
<
NodeID
,
HashSet
<
NodeID
>>
{
let
reduces
=
(
0
..
function
.nodes
.len
())
.filter
(|
idx
|
function
.nodes
[
*
idx
]
.is_reduce
())
.map
(
NodeID
::
new
);
let
mut
result
=
HashMap
::
new
();
let
join_fork_map
:
HashMap
<
NodeID
,
NodeID
>
=
fork_join_map
.into_iter
()
.map
(|(
fork
,
join
)|
(
*
join
,
*
fork
))
.collect
();
for
reduce
in
reduces
{
let
(
_
,
_
,
reduct
)
=
function
.nodes
[
reduce
.idx
()]
.try_reduce
()
.unwrap
();
let
(
join
,
_
,
reduct
)
=
function
.nodes
[
reduce
.idx
()]
.try_reduce
()
.unwrap
();
let
fork
=
join_fork_map
[
&
join
];
// First, find all data nodes that are used by the `reduct` input of the
// reduce, including the `reduct` itself.
@@ -249,7 +256,13 @@ pub fn reduce_cycles(
let
mut
worklist
=
vec!
[
reduct
];
while
let
Some
(
item
)
=
worklist
.pop
()
{
for
u
in
get_uses
(
&
function
.nodes
[
item
.idx
()])
.as_ref
()
{
if
!
function
.nodes
[
u
.idx
()]
.is_control
()
&&
!
use_reachable
.contains
(
u
)
{
if
!
function
.nodes
[
u
.idx
()]
.is_control
()
&&
!
use_reachable
.contains
(
u
)
&&
function
.nodes
[
u
.idx
()]
.try_phi
()
.map
(|(
control
,
_
)|
fork_join_nest
[
&
fork
]
.contains
(
&
control
))
.unwrap_or
(
true
)
{
use_reachable
.insert
(
*
u
);
worklist
.push
(
*
u
);
}
Loading