Ignore:
Timestamp:
Aug 5, 2016, 8:27:14 AM (3 years ago)
Author:
cameron
Message:

Use bitblock_add_with_carry in carry_manager; add AVX2 implementation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/IDISA/idisa_avx_builder.cpp

    r5014 r5115  
    1010#include <llvm/IR/Intrinsics.h>
    1111#include <llvm/IR/Function.h>
     12#include <iostream>
    1213
    1314namespace IDISA {
     
    145146}
    146147   
     148std::pair<Value *, Value *> IDISA_AVX2_Builder::bitblock_add_with_carry(Value * e1, Value * e2, Value * carryin) {
     149    // using LONG_ADD
     150    Type * carryTy = carryin->getType();
     151    if (carryTy == mBitBlockType) {
     152        carryin = mvmd_extract(32, carryin, 0);
     153    }
     154    Value * carrygen = simd_and(e1, e2);
     155    Value * carryprop = simd_or(e1, e2);
     156    Value * digitsum = simd_add(64, e1, e2);
     157    Value * digitcarry = simd_or(carrygen, simd_and(carryprop, CreateNot(digitsum)));
     158    Value * carryMask = hsimd_signmask(64, digitcarry);
     159    Value * carryMask2 = CreateOr(CreateAdd(carryMask, carryMask), carryin);
     160    Value * bubble = simd_eq(64, digitsum, allOnes());
     161    Value * bubbleMask = hsimd_signmask(64, bubble);
     162    Value * incrementMask = CreateXor(CreateAdd(bubbleMask, carryMask2), bubbleMask);
     163    Value * increments = esimd_bitspread(64,incrementMask);
     164    Value * sum = simd_add(64, digitsum, increments);
     165    Value * carry_out = CreateLShr(incrementMask, mBitBlockWidth / 64);
     166    if (carryTy == mBitBlockType) {
     167        carry_out = bitCast(CreateZExt(carry_out, getIntNTy(mBitBlockWidth)));
     168    }
     169    return std::pair<Value *, Value *>(carry_out, bitCast(sum));
    147170}
     171   
     172}
Note: See TracChangeset for help on using the changeset viewer.