Lambda the Ultimate SSA: Optimizing Functional Programs in SSA

01/18/2022
by   Siddharth Bhat, et al.
0

Static Single Assignment (SSA) is the workhorse of modern optimizing compilers for imperative programming languages. However, functional languages have been slow to adopt SSA and prefer to use intermediate representations based on minimal lambda calculi due to SSA's inability to express higher order constructs. We exploit a new SSA construct – regions – in order to express functional optimizations via classical SSA based reasoning. Region optimization currently relies on ad-hoc analyses and transformations on imperative programs. These ad-hoc transformations are sufficient for imperative languages as regions are used in a limited fashion. In contrast, we use regions pervasively to model sub-expressions in our functional IR. This motivates us to systematize region optimizations. We extend classical SSA reasoning to regions for functional-style analyses and transformations. We implement a new SSA+regions based backend for LEAN4, a theorem prover that implements a purely functional, dependently typed programming language. Our backend is feature-complete and handles all constructs of LEAN4's functional intermediate representation λrc within the SSA framework. We evaluate our proposed region optimizations by optimizing λrc within an SSA+regions based framework implemented in MLIR and demonstrating performance parity with the current LEAN4 backend. We believe our work will pave the way for a unified optimization framework capable of representing, analyzing, and optimizing both functional and imperative languages.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
02/06/2020

A Language for Describing Optimization Strategies

Optimizing programs to run efficiently on modern parallel hardware is ha...
research
11/09/2017

Cons-free Programming with Immutable Functions

We investigate the power of non-determinism in purely functional program...
research
12/10/2019

RVSDG: An Intermediate Representation for Optimizing Compilers

Intermediate Representations (IRs) are central to optimizing compilers a...
research
10/15/2021

Zipping Strategies and Attribute Grammars

Strategic term rewriting and attribute grammars are two powerful program...
research
06/13/2023

Efficient Iterative Programs with Distributed Data Collections

Big data programming frameworks have become increasingly important for...
research
04/07/2020

egg: Fast and Extensible E-graphs

An e-graph efficiently represents a congruence relation over many expres...
research
02/22/2019

Optimizing Space of Parallel Processes

This paper is a contribution to exploring and analyzing space-improvemen...

Please sign up or login with your details

Forgot password? Click here to reset