Changeset 6164


Ignore:
Timestamp:
Sep 19, 2018, 4:58:26 PM (5 weeks ago)
Author:
cameron
Message:

Reducing dependencies on mBitBlockWidth; use getVectorBitWidth

File:
1 edited

Legend:

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

    r6111 r6164  
    182182        return eq_bits;
    183183    }
    184     return CreateSExt(CreateICmpEQ(fwCast(fw, a), fwCast(fw, b)), fwVectorType(fw));
     184    Value * a1 = fwCast(fw, a);
     185    Value * b1 = fwCast(fw, b);
     186    return CreateSExt(CreateICmpEQ(a1, b1), a1->getType());
    185187}
    186188
    187189Value * IDISA_Builder::simd_gt(unsigned fw, Value * a, Value * b) {
    188190    if (fw < 8) UnsupportedFieldWidthError(fw, "gt");
    189     return CreateSExt(CreateICmpSGT(fwCast(fw, a), fwCast(fw, b)), fwVectorType(fw));
     191    Value * a1 = fwCast(fw, a);
     192    Value * b1 = fwCast(fw, b);
     193    return CreateSExt(CreateICmpSGT(a1, b1), a1->getType());
    190194}
    191195
     
    199203    }
    200204    if (fw < 8) UnsupportedFieldWidthError(fw, "ugt");
    201     return CreateSExt(CreateICmpUGT(fwCast(fw, a), fwCast(fw, b)), fwVectorType(fw));
     205    Value * a1 = fwCast(fw, a);
     206    Value * b1 = fwCast(fw, b);
     207    return CreateSExt(CreateICmpUGT(a1, b1), a1->getType());
    202208}
    203209
    204210Value * IDISA_Builder::simd_lt(unsigned fw, Value * a, Value * b) {
    205211    if (fw < 8) UnsupportedFieldWidthError(fw, "lt");
    206     return CreateSExt(CreateICmpSLT(fwCast(fw, a), fwCast(fw, b)), fwVectorType(fw));
     212    Value * a1 = fwCast(fw, a);
     213    Value * b1 = fwCast(fw, b);
     214    return CreateSExt(CreateICmpSLT(a1, b1), a1->getType());
    207215}
    208216
    209217Value * IDISA_Builder::simd_ult(unsigned fw, Value * a, Value * b) {
    210218    if (fw < 8) UnsupportedFieldWidthError(fw, "ult");
    211     return CreateSExt(CreateICmpULT(fwCast(fw, a), fwCast(fw, b)), fwVectorType(fw));
     219    Value * a1 = fwCast(fw, a);
     220    Value * b1 = fwCast(fw, b);
     221    return CreateSExt(CreateICmpULT(a1, b1), a1->getType());
    212222}
    213223
     
    219229        return simd_or(hi_rslt, lo_rslt);
    220230    }
    221     return CreateSExt(CreateICmpULE(fwCast(fw, a), fwCast(fw, b)), fwVectorType(fw));
     231    Value * a1 = fwCast(fw, a);
     232    Value * b1 = fwCast(fw, b);
     233    return CreateSExt(CreateICmpULE(a1, b1), a1->getType());
    222234}
    223235
     
    230242    }
    231243    if (fw < 8) UnsupportedFieldWidthError(fw, "ult");
    232     return CreateSExt(CreateICmpUGE(fwCast(fw, a), fwCast(fw, b)), fwVectorType(fw));
     244    Value * a1 = fwCast(fw, a);
     245    Value * b1 = fwCast(fw, b);
     246    return CreateSExt(CreateICmpUGE(a1, b1), a1->getType());
    233247}
    234248
     
    451465        Value * bitrev8 = fwCast(8, simd_bitreverse(8, a));
    452466        const auto bytes_per_field = fw/8;
    453         const auto byte_count = mBitBlockWidth / 8;
     467        const unsigned vectorWidth = getVectorBitWidth(a);
     468        const auto byte_count = vectorWidth / 8;
    454469        Constant * Idxs[byte_count];
    455470        for (unsigned i = 0; i < byte_count; i += bytes_per_field) {
     
    458473            }
    459474        }
    460         return CreateShuffleVector(bitrev8, UndefValue::get(fwVectorType(8)), ConstantVector::get({Idxs, byte_count}));
     475        return CreateShuffleVector(bitrev8, UndefValue::get(bitrev8->getType()), ConstantVector::get({Idxs, byte_count}));
    461476    }
    462477    else {
     
    616631Value * IDISA_Builder::hsimd_signmask(unsigned fw, Value * a) {
    617632    if (fw < 8) UnsupportedFieldWidthError(fw, "hsimd_signmask");
    618     Value * mask = CreateICmpSLT(fwCast(fw, a), ConstantAggregateZero::get(fwVectorType(fw)));
     633    Value * a1 = fwCast(fw, a);
     634    Value * mask = CreateICmpSLT(a1, ConstantAggregateZero::get(a1->getType()));
    619635    mask = CreateBitCast(mask, getIntNTy(mBitBlockWidth/fw));
    620636    if (mBitBlockWidth/fw < 32) return CreateZExt(mask, getInt32Ty());
     
    646662Value * IDISA_Builder::mvmd_slli(unsigned fw, Value * a, unsigned shift) {
    647663    if (fw < 8) UnsupportedFieldWidthError(fw, "mvmd_slli");
    648     Value * shifted = mvmd_dslli(fw, a, Constant::getNullValue(fwVectorType(fw)), shift);
     664    Value * a1 = fwCast(fw, a);
     665    Value * shifted = mvmd_dslli(fw, a1, Constant::getNullValue(a1->getType()), shift);
    649666    return shifted;
    650667}
     
    652669Value * IDISA_Builder::mvmd_srli(unsigned fw, Value * a, unsigned shift) {
    653670    if (fw < 8) UnsupportedFieldWidthError(fw, "mvmd_srli");
    654     const auto field_count = mBitBlockWidth / fw;
    655     return mvmd_dslli(fw, Constant::getNullValue(fwVectorType(fw)), a, field_count - shift);
     671    const auto field_count = getVectorBitWidth(a) / fw;
     672    Value * a1 = fwCast(fw, a);
     673    return mvmd_dslli(fw, Constant::getNullValue(a1->getType()), a1, field_count - shift);
    656674}
    657675
    658676Value * IDISA_Builder::mvmd_dslli(unsigned fw, Value * a, Value * b, unsigned shift) {
    659677    if (fw < 8) UnsupportedFieldWidthError(fw, "mvmd_dslli");
    660     const auto field_count = mBitBlockWidth/fw;
     678    const auto field_count = getVectorBitWidth(a) / fw;
    661679    Constant * Idxs[field_count];
    662680    for (unsigned i = 0; i < field_count; i++) {
     
    686704
    687705Value * IDISA_Builder::bitblock_any(Value * a) {
    688     Type * iBitBlock = getIntNTy(mBitBlockWidth);
     706    Type * iBitBlock = getIntNTy(getVectorBitWidth(a));
    689707    return CreateICmpNE(CreateBitCast(a, iBitBlock),  ConstantInt::getNullValue(iBitBlock));
    690708}
Note: See TracChangeset for help on using the changeset viewer.