Changeset 6016


Ignore:
Timestamp:
May 5, 2018, 3:27:08 PM (6 months ago)
Author:
cameron
Message:

AVX-512 support for mvmd_srl, mvme_sll

Location:
icGREP/icgrep-devel/icgrep/IR_Gen
Files:
2 edited

Legend:

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

    r6015 r6016  
    286286    return IDISA_AVX_Builder::hsimd_signmask(fw, a);
    287287}
    288    
     288
    289289llvm::Value * IDISA_AVX2_Builder::mvmd_compress(unsigned fw, llvm::Value * a, llvm::Value * select_mask) {
    290290    if (mBitBlockWidth == 256 && fw == 32) {
     
    406406}
    407407
     408llvm::Value * IDISA_AVX512F_Builder::mvmd_srl(unsigned fw, llvm::Value * a, llvm::Value * shift) {
     409    const unsigned fieldCount = mBitBlockWidth/fw;
     410    Type * fieldTy = getIntNTy(fw);
     411    Constant * indexes[fieldCount];
     412    for (unsigned int i = 0; i < fieldCount; i++) {
     413        indexes[i] = ConstantInt::get(fieldTy, i);
     414    }
     415    Constant * indexVec = ConstantVector::get({indexes, fieldCount});
     416    Value * permuteVec = CreateAdd(indexVec, simd_fill(fw, CreateZExtOrTrunc(shift, fieldTy)));
     417    Constant * mask = ConstantInt::getAllOnesValue(getIntNTy(fieldCount));
     418    if (mBitBlockWidth == 512) {
     419        Value * permuteFunc = nullptr;
     420        if (fw == 64) permuteFunc = Intrinsic::getDeclaration(getModule(), Intrinsic::x86_avx512_mask_vpermt2var_q_512);
     421        else if (fw == 32) permuteFunc = Intrinsic::getDeclaration(getModule(), Intrinsic::x86_avx512_mask_vpermt2var_d_512);
     422        if (permuteFunc) {
     423            Value * shifted = CreateCall(permuteFunc, {permuteVec, fwCast(fw, a), fwCast(fw, allZeroes()), mask});
     424            return shifted;
     425        }
     426    }
     427    return IDISA_Builder::mvmd_srl(fw, a, shift);
     428}
     429 
     430llvm::Value * IDISA_AVX512F_Builder::mvmd_sll(unsigned fw, llvm::Value * a, llvm::Value * shift) {
     431    const unsigned fieldCount = mBitBlockWidth/fw;
     432    Type * fieldTy = getIntNTy(fw);
     433    Constant * indexes[fieldCount];
     434    for (unsigned int i = 0; i < fieldCount; i++) {
     435        indexes[i] = ConstantInt::get(fieldTy, fieldCount + i);
     436    }
     437    Constant * indexVec = ConstantVector::get({indexes, fieldCount});
     438    Value * permuteVec = CreateSub(indexVec, simd_fill(fw, CreateZExtOrTrunc(shift, fieldTy)));
     439    Constant * mask = ConstantInt::getAllOnesValue(getIntNTy(fieldCount));
     440    if (mBitBlockWidth == 512) {
     441        Value * permuteFunc = nullptr;
     442        if (fw == 64) permuteFunc = Intrinsic::getDeclaration(getModule(), Intrinsic::x86_avx512_mask_vpermt2var_q_512);
     443        else if (fw == 32) permuteFunc = Intrinsic::getDeclaration(getModule(), Intrinsic::x86_avx512_mask_vpermt2var_d_512);
     444        if (permuteFunc) {
     445            Value * shifted = CreateCall(permuteFunc, {permuteVec, fwCast(fw, allZeroes()), fwCast(fw, a), mask});
     446            return shifted;
     447        }
     448    }
     449    return IDISA_Builder::mvmd_sll(fw, a, shift);
     450}
     451
     452
    408453llvm::Value * IDISA_AVX512F_Builder::mvmd_compress(unsigned fw, llvm::Value * a, llvm::Value * select_mask) {
    409454   
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_avx_builder.h

    r6011 r6016  
    7474    llvm::Value * hsimd_signmask(unsigned fw, llvm::Value * a) override;
    7575    llvm::Value * mvmd_compress(unsigned fw, llvm::Value * a, llvm::Value * select_mask) override;
     76    llvm::Value * mvmd_srl(unsigned fw, llvm::Value * a, llvm::Value * shift) override;
     77    llvm::Value * mvmd_sll(unsigned fw, llvm::Value * a, llvm::Value * shift) override;
    7678
    7779    ~IDISA_AVX512F_Builder() {
Note: See TracChangeset for help on using the changeset viewer.