Skip to content

Commit

Permalink
Address review comments + new snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
ezrosent committed May 30, 2024
1 parent 496a7a9 commit 41fae5f
Show file tree
Hide file tree
Showing 24 changed files with 314 additions and 1,066 deletions.
2 changes: 1 addition & 1 deletion src/rvsdg/optimize_direct_jumps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl SimpleCfgProgram {
// NB: We could avoid this copy by having `optimize_jumps` take `self` by value.
let mut res = f.optimize_jumps();
res.simplify_branches();
res.optimize_jumps()
res
})
.collect(),
}
Expand Down
289 changes: 159 additions & 130 deletions src/rvsdg/simplify_branches.rs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ expression: prog.to_string()
v11: int = load v4;
v14: bool = lt v11 v7;
br v14 .__39__ .__32__;
.__32__:
v24: int = add v11 v1;
.__39__:
print v11;
free v4;
print v24;
v31: int = id v7;
print v31;
ret;
.__39__:
print v11;
.__32__:
v24: int = add v11 v1;
free v4;
print v24;
v31: int = id v7;
.__42__:
print v31;
Expand Down
34 changes: 0 additions & 34 deletions tests/snapshots/files__block-diamond-optimize.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ expression: visualization.result
c2_: int = const 2;
v3_: bool = lt v0 c2_;
v4_: bool = not v3_;
<<<<<<< HEAD
c5_: int = const 0;
c6_: int = const 1;
c7_: int = const 5;
Expand Down Expand Up @@ -35,37 +34,4 @@ expression: visualization.result
.b20_:
v22_: int = add c6_ v17_;
print v22_;
=======
v5_: int = const 0;
v6_: int = const 1;
v7_: int = const 5;
v8_: bool = const true;
v9_: int = id v6_;
v10_: int = id v6_;
v11_: int = id v2_;
v12_: bool = id v8_;
br v3_ .v13_ .v14_;
.v14_:
v15_: int = id v9_;
v16_: int = id v6_;
br v4_ .v17_ .v18_;
.v17_:
v19_: int = add v2_ v9_;
v15_: int = id v19_;
v16_: int = id v6_;
v20_: int = add v15_ v6_;
print v20_;
ret;
.v13_:
v21_: int = const 4;
v22_: bool = const false;
v9_: int = id v21_;
v10_: int = id v6_;
v11_: int = id v2_;
v12_: bool = id v22_;
jmp .v14_;
.v18_:
v20_: int = add v15_ v6_;
print v20_;
>>>>>>> b975e017 (Run branch_simplify in a fixed point)
}
18 changes: 0 additions & 18 deletions tests/snapshots/files__branch_duplicate_work-optimize.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ source: tests/files.rs
expression: visualization.result
---
@main(v0: int) {
<<<<<<< HEAD
.b1_:
c2_: int = const 2;
v3_: bool = lt v0 c2_;
Expand All @@ -19,21 +18,4 @@ expression: visualization.result
v7_: int = id v9_;
.b10_:
print v7_;
=======
.v1_:
v2_: int = const 2;
v3_: bool = lt v0 v2_;
br v3_ .v4_ .v5_;
.v5_:
v6_: int = add v0 v0;
v7_: int = mul v2_ v6_;
v8_: int = id v7_;
print v8_;
ret;
.v4_:
v9_: int = add v0 v0;
v8_: int = id v9_;
.v10_:
print v8_;
>>>>>>> b975e017 (Run branch_simplify in a fixed point)
}
48 changes: 0 additions & 48 deletions tests/snapshots/files__collatz_redundant_computation-optimize.snap
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ expression: visualization.result
v19_: int = id v9_;
v20_: int = id v10_;
v21_: int = id v11_;
<<<<<<< HEAD
br v13_ .b22_ .b23_;
.b23_:
v24_: int = div v7_ v10_;
Expand Down Expand Up @@ -63,60 +62,13 @@ expression: visualization.result
v21_: int = id v11_;
.b22_:
v42_: bool = not v13_;
=======
br v13_ .v22_ .v23_;
.v22_:
v24_: bool = not v13_;
>>>>>>> b975e017 (Run branch_simplify in a fixed point)
v6_: int = id v6_;
v7_: int = id v17_;
v8_: int = id v8_;
v9_: int = id v9_;
v10_: int = id v10_;
v11_: int = id v11_;
<<<<<<< HEAD
br v42_ .b12_ .b43_;
.b43_:
=======
br v24_ .v12_ .v25_;
.v23_:
v26_: int = div v7_ v10_;
v27_: int = mul v10_ v26_;
v28_: int = sub v7_ v27_;
v29_: bool = eq v11_ v28_;
print v7_;
v30_: int = mul v7_ v9_;
v31_: int = add v30_ v8_;
v32_: bool = const true;
v33_: int = id v6_;
v34_: bool = id v32_;
v35_: int = id v31_;
v36_: int = id v8_;
v37_: int = id v9_;
v38_: int = id v10_;
v39_: int = id v11_;
br v29_ .v40_ .v41_;
.v41_:
v42_: bool = const true;
v15_: int = id v6_;
v16_: bool = id v42_;
v17_: int = id v35_;
v18_: int = id v8_;
v19_: int = id v9_;
v20_: int = id v10_;
v21_: int = id v11_;
jmp .v22_;
.v40_:
v43_: bool = const true;
v33_: int = id v6_;
v34_: bool = id v43_;
v35_: int = id v26_;
v36_: int = id v8_;
v37_: int = id v9_;
v38_: int = id v10_;
v39_: int = id v11_;
jmp .v41_;
.v25_:
>>>>>>> b975e017 (Run branch_simplify in a fixed point)
print v0;
}
12 changes: 0 additions & 12 deletions tests/snapshots/files__diamond-optimize.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ expression: visualization.result
@main(v0: int) {
.b1_:
v2_: bool = lt v0 v0;
<<<<<<< HEAD
br v2_ .b3_ .b4_;
.b3_:
c5_: int = const 1;
Expand All @@ -15,15 +14,4 @@ expression: visualization.result
c6_: int = const 2;
print c6_;
.b7_:
=======
br v2_ .v3_ .v4_;
.v4_:
v5_: int = const 2;
print v5_;
ret;
.v3_:
v6_: int = const 1;
print v6_;
.v7_:
>>>>>>> b975e017 (Run branch_simplify in a fixed point)
}
Loading

0 comments on commit 41fae5f

Please sign in to comment.