aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Corallo2020-07-05 11:11:11 +0100
committerAndrea Corallo2020-07-09 16:22:37 +0100
commite6ab4e3dfe2bfc6e935b4cfa7e8f686e5d926235 (patch)
treed186f704d419aa19a9f8e03203f5b8ca86111177
parentb31b0ebefef3c9ea378342f624ce18a0eb6d30ae (diff)
downloademacs-e6ab4e3dfe2bfc6e935b4cfa7e8f686e5d926235.tar.gz
emacs-e6ab4e3dfe2bfc6e935b4cfa7e8f686e5d926235.zip
* Add a test targeting forward propagation
* test/src/comp-tests.el (comp-tests-fw-prop-checker-1): New function. (comp-tests-fw-prop): New test.
-rw-r--r--test/src/comp-tests.el22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el
index aefb2f0601a..332facb4cf9 100644
--- a/test/src/comp-tests.el
+++ b/test/src/comp-tests.el
@@ -640,4 +640,26 @@ CHECKER should always return nil to have a pass."
640 (should (subr-native-elisp-p (symbol-function #'comp-tests-tco-f))) 640 (should (subr-native-elisp-p (symbol-function #'comp-tests-tco-f)))
641 (should (= (comp-tests-tco-f 1 0 10) 55)))) 641 (should (= (comp-tests-tco-f 1 0 10) 55))))
642 642
643(defun comp-tests-fw-prop-checker-1 (_)
644 "Check that inside `comp-tests-fw-prop-f' `concat' and `length' are folded."
645 (comp-tests-make-insn-checker
646 'comp-tests-fw-prop-1-f
647 (lambda (insn)
648 (or (comp-tests-mentioned-p 'concat insn)
649 (comp-tests-mentioned-p 'length insn)))))
650
651(ert-deftest comp-tests-fw-prop ()
652 "Some tests for forward propagation."
653 (let ((comp-speed 2)
654 (comp-post-pass-hooks '((comp-final comp-tests-fw-prop-checker-1))))
655 (eval '(defun comp-tests-fw-prop-1-f ()
656 (let* ((a "xxx")
657 (b "yyy")
658 (c (concat a b))) ; <= has to optimize
659 (length c))) ; <= has to optimize
660 t)
661 (load (native-compile #'comp-tests-fw-prop-1-f))
662 (should (subr-native-elisp-p (symbol-function #'comp-tests-fw-prop-1-f)))
663 (should (= (comp-tests-fw-prop-1-f) 6))))
664
643;;; comp-tests.el ends here 665;;; comp-tests.el ends here