Abstract
The increasing sizes of modern applications significantly hinder user acquisition and updates, particularly in computing environments constrained by memory and storage capacities. To address this challenge, our article presents a novel assembly code optimization framework aimed at reducing application size. Unlike traditional compiler-based optimizations that require intricate knowledge of compiler architectures and are tightly integrated within specific toolchains, our approach operates independently of compiling modules at the assembly code level, offering a universal solution applicable across various computing environments. This decoupled design allows for substantial code size reductions without sacrificing functionality or performance. By taking RISC-V ISA as a case study, the experimental results show that our approach can outperform the default optimization levels (e.g., ‘-Oz’ and ‘-O3’), with an improvement of up to 6% in code size reduction. Our findings present a practical and effective strategy for code size optimization, particularly beneficial for memory-constrained embedded systems and storage-sensitive mobile devices, thereby facilitating broader application accessibility and enhanced update processes.
Similar content being viewed by others
Data availability
The data that support the findings of this study are available from the corresponding author upon reasonable request.
Notes
RACO is available via https://github.com/Solitono/RACO
https://github.com/riscv-collab/riscv-gnu-toolchain.
References
Badri, M., Badri, L., Flageol, W., Toure, F.: Investigating the accuracy of test code size prediction using use case metrics and machine learning algorithms: An empirical study. In: Proceedings of the 2017 International Conference on Machine Learning and Soft Computing. ICMLSC ’17, pp. 25–33. Association for Computing Machinery, New York, NY, USA (2017). https://doi.org/10.1145/3036290.3036323
Beszédes, Á., Ferenc, R., Gyimóthy, T., Dolenc, A., Karsisto, K.: Survey of code-size reduction methods. ACM Comput. Surv. 35(3), 223–267 (2003). https://doi.org/10.1145/937503.937504
Chabbi, M., Lin, J., Barik, R.: An experience with code-size optimization for production ios mobile applications. In: 2021 IEEE/ACM International Symposium on Code Generation and Optimization (CGO), pp. 363–377 (2021). https://doi.org/10.1109/CGO51591.2021.9370306
Damásio, T., Pacheco, V., Goes, F., Pereira, F., Rocha, R.: Inlining for code size reduction. In: Proceedings of the 25th Brazilian Symposium on Programming Languages. SBLP ’21, pp. 17–24. Association for Computing Machinery, New York, NY, USA (2021). https://doi.org/10.1145/3475061.3475081
Kusswurm, D.: Assembly Language Optimization and Development Guidelines, pp. 639–648. Apress, Berkeley, CA (2023). https://doi.org/10.1007/978-1-4842-9603-5_17
Liu, M.: The risc-v instruction set architecture optimization and fixed-point math library co-design: work-in-progress. In: Proceedings of the 2021 International Conference on Hardware/Software Codesign and System Synthesis. CODES/ISSS ’21, pp. 23–24. Association for Computing Machinery, New York, NY, USA (2021). https://doi.org/10.1145/3478684.3479250
Lozano, H., Ito, M.: Increasing the code density of embedded risc applications. In: 2016 IEEE 19th International Symposium on Real-Time Distributed Computing (ISORC), pp. 182–189 (2016). https://doi.org/10.1109/ISORC.2016.33
Mahale, G., Limbasiya, T., Aleem, M.A., Plana, L., Duricic, A., Monemi, A., Abancens, X., Cervero, T., Davis, J.D.: Optimizations for very long and sparse vector operations on a risc-v vpu: a work-in-progress. In: Bienz, A., Weiland, M., Baboulin, M., Kruse, C. (eds.) High Performance Computing, pp. 472–485. Springer, Cham (2023)
Mosaner, R., Leopoldseder, D., Stadler, L., Mössenböck, H.: Using machine learning to predict the code size impact of duplication heuristics in a dynamic compiler. In: Proceedings of the 18th ACM SIGPLAN International Conference on Managed Programming Languages and Runtimes. MPLR 2021, pp. 127–135. Association for Computing Machinery, New York, NY, USA (2021). https://doi.org/10.1145/3475738.3480943
Perotti, M., Schiavone, P.D., Tagliavini, G., Rossi, D., Kurd, T., Hill, M.D., Yingying, L., Benini, L.: Hw/sw approaches for risc-v code size reduction. (2020). https://api.semanticscholar.org/CorpusID:235847879
Rocha, R.C.O., Petoumenos, P., Franke, B., Bhatotia, P., O’Boyle, M.: Loop rolling for code size reduction. In: 2022 IEEE/ACM International Symposium on Code Generation and Optimization (CGO), pp. 217–229 (2022). https://doi.org/10.1109/CGO53902.2022.9741256
Rocha, R.C.O., Saumya, C., Sundararajah, K., Petoumenos, P., Kulkarni, M., O’Boyle, M.F.P.: Hybf: A hybrid branch fusion strategy for code size reduction. In: Proceedings of the 32nd ACM SIGPLAN International Conference on Compiler Construction. CC 2023, pp. 156–167. Association for Computing Machinery, New York, NY, USA (2023). https://doi.org/10.1145/3578360.3580267
Stallman, R.M., GCC Developer Community: Using the GNU Compiler Collection (GCC). GNU Press, (2023). GNU Press. Available from GNU Press, Free Software Foundation: http://www.gnupress.org
Team, L.: LLVM Clang User Manual. Accessed on Febrary 1th, 2024 (2023). https://releases.llvm.org/17.0.1/tools/clang/docs/UsersManual.html
Waterman, A.: Improving energy efficiency and reducing code size with risc-v compressed. Master’s thesis, EECS Department, University of California, Berkeley (2011). http://www2.eecs.berkeley.edu/Pubs/TechRpts/2011/EECS-2011-63.html
Waterman, A., Asanović, K.: The RISC-V Instruction Set Manual, Volume I: User-Level ISA. RISC-V Foundation, (2019). RISC-V Foundation. Available from https://riscv.org/technical/specifications/
Yu, B., Cao, H., Shan, T., Wang, H., Tang, X., Chen, W.: Sparker: Efficient reduction for more scalable machine learning with spark. In: Proceedings of the 50th International Conference on Parallel Processing. ICPP ’21. Association for Computing Machinery, New York, NY, USA (2021). https://doi.org/10.1145/3472456.3472499
Author information
Authors and Affiliations
Corresponding authors
Ethics declarations
Conflict of interest
On behalf of all authors, the corresponding author states that there is no Conflict of interest.
Rights and permissions
Springer Nature or its licensor (e.g. a society or other partner) holds exclusive rights to this article under a publishing agreement with the author(s) or other rightsholder(s); author self-archiving of the accepted manuscript version of this article is solely governed by the terms of such publishing agreement and applicable law.
About this article
Cite this article
Liu, J., Gao, W., Liang, H. et al. Towards a universal and portable assembly code size reduction: a case study of RISC-V ISA. CCF Trans. HPC (2024). https://doi.org/10.1007/s42514-024-00190-2
Received:
Accepted:
Published:
DOI: https://doi.org/10.1007/s42514-024-00190-2