Version 10 (modified by cameron, 5 years ago) (diff)


The Complete Integer Project

This project involves systematic support for integers and vectors of integers in all power-of-2 configurations up to N bits, where N = 256 (or possibly 512 or 1024).

In general, this project seeks to "fill in the gaps" of LLVM support, specifically as follows.

  1. Add first class support for short integer types i1, i2, i4.
  2. Add first class support for LongInteger types i128, ...
  3. Add first class support for vectors of integers of i1, i2 and i4 types up to <N x i1>, <N/2 x i2>, <N/4 x i4>.
  4. Add first class support for vectors of long integers <N/128 x i128>, ...


This file has the complete list of types "that is supported natively by some processor targeted by LLVM". At present it includes some of the types (notably 32xi1 and 64xi1) targeted by the project, but lacks many as well. This file and include/llvm/CodeGen/ValueTypes.Td need to be updated with the complete set.

Short Integer Types

Should the i1, i2, i4 types be legalized? They seem to arise in some SIMD operations such as the natural bitcast from <2 x i1> to i2.

The I2Result bug needs to be addressed.

Vectors of short integers may be more important than the short integers themselves.

Long Integer Project

Parabix applications need long stream addition, subtraction and shift operations. There are standard ways of implementing these, including our parallel long-stream addition algorithm. Can these be integrated into LLVM?

The LongInteger project involves systematic support of the i256 type on LLVM, taking advantage of AVX2 instructions on the latest Intel Haswell chips.

Vectors of Short Integers

The types <32 x i1> and <64 x i1> are particularly important to legalize, so that the BitShuffle subproject can be implemented.

Example: 2-bit Fields

There can be some applications of 2-bit integer fields, i.e., the SIMD vector type <64 x i2> for 128-bit SIMD registers.

Can this be implemented in a generic way as follows:

  1. Make it a legal type in the SelectionDAG LegalizeTypes phase.
  2. Create implementations of the standard vector operations and rule out all others in the SelectionDAG Legalize phase.
  3. Implement each operation using bitwise logic on the 2 positions of each field.

We explore this possibility with the i2Vector project.

Type Legalization

Legalizing Types


The VR128 class should be extended, it seems.


def VR128 : RegisterClass<"X86", [v16i8, v8i16, v4i32, v2i64, v4f32, v2f64],
                          128, (add FR32)>;


def VR128 : RegisterClass<"X86", [v128i1, v64i2, v32i4, v16i8, v8i16, v4i32, v2i64, v1i128, v4f32, v2f64],
                          128, (add FR32)>;

Similar changes for VR256 and VR512 can be applied for the AVX and AVX-512 cases. Perhaps VR64 could also be extended if we want to support the use of MMX registers.


New addRegisterClass statements required.

The i1 vector types.

addRegisterClass(MVT::v32i1, &X86::GR32RegClass);
addRegisterClass(MVT::v64i1, &X86::GR64RegClass);
addRegisterClass(MVT::v128i1, &X86::VR128RegClass);
addRegisterClass(MVT::v256i1, &X86::VR256RegClass);
addRegisterClass(MVT::v512i1, &X86::VR512RegClass);

The i2 vector types.

addRegisterClass(MVT::v16i2, &X86::GR32RegClass);
addRegisterClass(MVT::v32i2, &X86::GR64RegClass);
addRegisterClass(MVT::v64i2, &X86::VR128RegClass);
addRegisterClass(MVT::v128i2, &X86::VR256RegClass);
addRegisterClass(MVT::v256i2, &X86::VR512RegClass);

The i4 vector types.

addRegisterClass(MVT::v8i4, &X86::GR32RegClass);
addRegisterClass(MVT::v16i4, &X86::GR64RegClass);
addRegisterClass(MVT::v32i4, &X86::VR128RegClass);
addRegisterClass(MVT::v64i4, &X86::VR256RegClass);
addRegisterClass(MVT::v128i4, &X86::VR512RegClass);

Additional vector types.

addRegisterClass(MVT::v4i8, &X86::GR32RegClass);
addRegisterClass(MVT::v2i16, &X86::GR32RegClass);
addRegisterClass(MVT::v8i8, &X86::GR64RegClass);
addRegisterClass(MVT::v4i16, &X86::GR64RegClass);
addRegisterClass(MVT::v2i32, &X86::GR64RegClass);

Vectors of Long Integers

Right now, this seems like the least important of the subjprojects here, but is included for completeness.

Li QiPing's GitHub