Code Monkey home page Code Monkey logo

strengthreductionpass's Introduction

Strength Reduction Pass Project

The LLVM Strength Reduction Pass, developed at the Faculty of Mathematics of the University of Belgrade, is a compiler optimization project that transforms specific operations into more efficient ones. In particular, the optimization pass does strength reduction (replacing slower operations with faster ones) on induction variables in loops, and some arithmetic operations for powers of two.

Strength reduction for induction variables

Compilation and invocation:

clang -S -fno-discard-value-names -emit-llvm -O0 -Xclang -disable-O0-optnone <input> -o <output.ll>
opt   -S -load path/to/lib/MatfStrengthReductionPass -mem2reg -matf-iv-sr -enable-new-pm=0 <input>

Check out directory indVarTest for a small example test.

Replacing expansive operations with cheaper ones

  • Multiplication by a power of 2 is replaced by left-shifting
  • Dividision by a power of 2 is replaced by right-shifting
  • Modulo by a power of 2 is replaced with logical and using a mask

Compilation and invocation:

clang -S -fno-discard-value-names -emit-llvm -O0 -Xclang -disable-O0-optnone <input> -o <output.ll>
clang -S -load path/to/lib/MatfStrengthReductionPass -matf-arit-sr -enable-new-pm=0 <input>

Test Script

test.sh compiles and runs C/C++ the programs in TestPrograms directory. Use the -k flag to keep the .ll files.

Programs are timed before and after the optimization pass, and outputs are compared to determine whether the opt is at least somewhat correct.


Contributors:

  • Matija Lojović - 45/2018
  • Radovan Božić - 172/2018
  • Luka Colić - 31/2018

strengthreductionpass's People

Contributors

armapillow avatar lcenzo-qcerris avatar lcenzo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.