Changeset 6234 for icGREP


Ignore:
Timestamp:
Dec 15, 2018, 12:40:07 PM (4 months ago)
Author:
cameron
Message:

Verifying availability of BMI2 instructions

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

Legend:

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

    r6184 r6234  
    206206
    207207Value * IDISA_AVX2_Builder::simd_pext(unsigned fieldwidth, Value * v, Value * extract_mask) {
    208     if ((fieldwidth == 64) || (fieldwidth == 32)) {
     208    if (hasBMI2 && ((fieldwidth == 64) || (fieldwidth == 32))) {
    209209        Value * PEXT_f = (fieldwidth == 64) ? Intrinsic::getDeclaration(getModule(), Intrinsic::x86_bmi_pext_64)
    210210                                            : Intrinsic::getDeclaration(getModule(), Intrinsic::x86_bmi_pext_32);
     
    223223
    224224Value * IDISA_AVX2_Builder::simd_pdep(unsigned fieldwidth, Value * v, Value * deposit_mask) {
    225     if ((fieldwidth == 64) || (fieldwidth == 32)) {
     225    if (hasBMI2 && ((fieldwidth == 64) || (fieldwidth == 32))) {
    226226        Value * PDEP_f = (fieldwidth == 64) ? Intrinsic::getDeclaration(getModule(), Intrinsic::x86_bmi_pdep_64)
    227227                                            : Intrinsic::getDeclaration(getModule(), Intrinsic::x86_bmi_pdep_32);
     
    241241std::pair<Value *, Value *> IDISA_AVX2_Builder::bitblock_indexed_advance(Value * strm, Value * index_strm, Value * shiftIn, unsigned shiftAmount) {
    242242    const unsigned bitWidth = getSizeTy()->getBitWidth();
    243     if ((bitWidth == 64) || (bitWidth == 32)) {
     243    if (hasBMI2 && ((bitWidth == 64) || (bitWidth == 32))) {
    244244        Value * PEXT_f = (bitWidth == 64) ? Intrinsic::getDeclaration(getModule(), Intrinsic::x86_bmi_pext_64)
    245245                                          : Intrinsic::getDeclaration(getModule(), Intrinsic::x86_bmi_pext_32);
     
    410410
    411411llvm::Value * IDISA_AVX2_Builder::mvmd_compress(unsigned fw, llvm::Value * a, llvm::Value * select_mask) {
    412     if (mBitBlockWidth == 256 && fw == 64) {
     412    if (hasBMI2 && (mBitBlockWidth == 256) && (fw == 64)) {
    413413        Value * PDEP_func = Intrinsic::getDeclaration(getModule(), Intrinsic::x86_bmi_pdep_32);
    414414        Value * mask = CreateZExt(select_mask, getInt32Ty());
     
    417417        return result;
    418418    }
    419     if (mBitBlockWidth == 256 && fw == 32) {
     419    if (hasBMI2 && (mBitBlockWidth == 256) && (fw == 32)) {
    420420        Type * v1xi32Ty = VectorType::get(getInt32Ty(), 1);
    421421        Type * v8xi32Ty = VectorType::get(getInt32Ty(), 8);
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_avx_builder.h

    r6184 r6234  
    2222    , IDISA_SSE2_Builder(C, vectorWidth, laneWidth)
    2323    {
    24 
    2524    }
    2625
     
    3029
    3130    ~IDISA_AVX_Builder() {}
    32 
    3331};
    3432
     
    3937    : IDISA_Builder(C, AVX_width, vectorWidth, laneWidth)
    4038    , IDISA_AVX_Builder(C, vectorWidth, laneWidth) {
    41 
     39        llvm::StringMap<bool> features;
     40        hasBMI2 = llvm::sys::getHostCPUFeatures(features) && features.lookup("bmi2");
    4241    }
    4342
     
    6160
    6261    ~IDISA_AVX2_Builder() {}
     62protected:
     63    bool hasBMI2;
    6364};
    6465
Note: See TracChangeset for help on using the changeset viewer.