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
!98
Clone elimination pass
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Clone elimination pass
clone_elimination
into
main
Overview
0
Commits
1
Pipelines
1
Changes
5
Merged
rarbore2
requested to merge
clone_elimination
into
main
3 months ago
Overview
0
Commits
1
Pipelines
1
Changes
5
Expand
Very simple clone elimination pass.
Rewrite matmul to not use implicit clones. Admitting defeat for now.
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
b141ac3c
1 commit,
3 months ago
5 files
+
75
−
3
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
5
Search (e.g. *.vue) (Ctrl+P)
hercules_opt/src/clone_elim.rs
0 → 100644
+
33
−
0
Options
extern
crate
hercules_ir
;
use
std
::
collections
::
BTreeSet
;
use
self
::
hercules_ir
::
ir
::
*
;
use
crate
::
*
;
/*
* Top level function to run clone elimination.
*/
pub
fn
clone_elim
(
editor
:
&
mut
FunctionEditor
)
{
// Create workset (starts as all nodes).
let
mut
workset
:
BTreeSet
<
NodeID
>
=
(
0
..
editor
.func
()
.nodes
.len
())
.map
(
NodeID
::
new
)
.collect
();
while
let
Some
(
work
)
=
workset
.pop_first
()
{
// Look for Write nodes with identical `collect` and `data` inputs.
let
nodes
=
&
editor
.func
()
.nodes
;
if
let
Node
::
Write
{
collect
,
data
,
ref
indices
,
}
=
nodes
[
work
.idx
()]
&&
nodes
[
collect
.idx
()]
==
nodes
[
data
.idx
()]
{
assert!
(
indices
.is_empty
());
editor
.edit
(|
edit
|
edit
.replace_all_uses
(
work
,
collect
)
?
.delete_node
(
work
));
// Removing this write may affect downstream writes.
workset
.extend
(
editor
.get_users
(
work
));
}
}
}
Loading