Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Add more tests with different inline arrangements
Browse files Browse the repository at this point in the history
  • Loading branch information
prozacchiwawa committed Jun 26, 2023
1 parent b7eae95 commit 2884260
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 0 deletions.
20 changes: 20 additions & 0 deletions resources/tests/strict/cse_doesnt_dominate_superior_let_iodi.clsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
(mod (X)
(include *standard-cl-23*)

(defun-inline L (Z X) (* (+ Z 1) (+ Z 1) (+ Z 1) (+ X 1) (+ X 1) (+ X 1)))

;; (+ X 1) should be an eliminated subexpression but it doesn't dominate the
;; condition.
(defun-inline F1 (X)
(let ((Z X))
(if X
(L Z X)
17
)
)
)

(defun F (X) (F1 X))

(F X)
)
18 changes: 18 additions & 0 deletions resources/tests/strict/cse_doesnt_dominate_superior_let_odi.clsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(mod (X)
(include *standard-cl-23*)

;; (+ X 1) should be an eliminated subexpression but it doesn't dominate the
;; condition.
(defun-inline F1 (X)
(let ((Z X))
(if X
(* (+ Z 1) (+ Z 1) (+ Z 1) (+ X 1) (+ X 1) (+ X 1))
17
)
)
)

(defun F (X) (F1 X))

(F X)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(mod (X)
(include *standard-cl-23*)

;; (+ X 1) should be an eliminated subexpression but it doesn't dominate the
;; condition.
(defun F (X)
(let ((Z X))
(if X
(* (+ Z 1) (+ Z 1) (+ Z 1) (+ X 1) (+ X 1) (+ X 1))
17
)
)
)

(F X)
)
39 changes: 39 additions & 0 deletions src/tests/classic/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2139,3 +2139,42 @@ fn test_cse_not_dominating_conditions_with_superior_let_outside_in_inline() {
.to_string();
assert_eq!(outcome, "0x5c13d840"); // 34 * 34 * 34 * 34 * 34 * 34
}

#[test]
fn test_cse_not_dominating_conditions_with_superior_let_outside_in_defun() {
let program = do_basic_run(&vec![
"run".to_string(),
"resources/tests/strict/cse_doesnt_dominate_superior_let_outside_in_defun.clsp"
.to_string(),
]);
let outcome = do_basic_brun(&vec!["brun".to_string(), program, "(33)".to_string()])
.trim()
.to_string();
assert_eq!(outcome, "0x5c13d840"); // 34 * 34 * 34 * 34 * 34 * 34
}

#[test]
fn test_cse_not_dominating_conditions_with_superior_let_odi() {
let program = do_basic_run(&vec![
"run".to_string(),
"resources/tests/strict/cse_doesnt_dominate_superior_let_odi.clsp"
.to_string(),
]);
let outcome = do_basic_brun(&vec!["brun".to_string(), program, "(33)".to_string()])
.trim()
.to_string();
assert_eq!(outcome, "0x5c13d840"); // 34 * 34 * 34 * 34 * 34 * 34
}

#[test]
fn test_cse_not_dominating_conditions_with_superior_let_iodi() {
let program = do_basic_run(&vec![
"run".to_string(),
"resources/tests/strict/cse_doesnt_dominate_superior_let_iodi.clsp"
.to_string(),
]);
let outcome = do_basic_brun(&vec!["brun".to_string(), program, "(33)".to_string()])
.trim()
.to_string();
assert_eq!(outcome, "0x5c13d840"); // 34 * 34 * 34 * 34 * 34 * 34
}

0 comments on commit 2884260

Please sign in to comment.