Ignore:
Timestamp:
May 20, 2018, 3:38:31 PM (17 months ago)
Author:
cameron
Message:

IDISA test checking, more test operations, IDISA fixes

File:
1 edited

Legend:

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

    r6051 r6052  
    141141
    142142Value * IDISA_Builder::simd_ule(unsigned fw, Value * a, Value * b) {
    143     if (fw < 8) report_fatal_error("Unsupported field width: ult " + std::to_string(fw));
     143    if (fw == 1) return simd_or(simd_not(a), b);
     144    if (fw < 8) {
     145        Value * hi_rslt = simd_and(simd_himask(2*fw), simd_ule(2*fw, simd_and(simd_himask(2*fw), a), b));
     146        Value * lo_rslt = simd_and(simd_lomask(2*fw), simd_ule(2*fw, simd_and(simd_lomask(2*fw), a), simd_and(simd_lomask(2*fw), b)));
     147        return simd_or(hi_rslt, lo_rslt);
     148    }
    144149    return CreateSExt(CreateICmpULE(fwCast(fw, a), fwCast(fw, b)), fwVectorType(fw));
    145150}
    146151
    147152Value * IDISA_Builder::simd_uge(unsigned fw, Value * a, Value * b) {
     153    if (fw == 1) return simd_or(a, simd_not(b));
     154    if (fw < 8) {
     155        Value * hi_rslt = simd_and(simd_himask(2*fw), simd_uge(2*fw, a, simd_and(simd_himask(2*fw), b)));
     156        Value * lo_rslt = simd_and(simd_lomask(2*fw), simd_uge(2*fw, simd_and(simd_lomask(2*fw), a), simd_and(simd_lomask(2*fw), b)));
     157        return simd_or(hi_rslt, lo_rslt);
     158    }
    148159    if (fw < 8) report_fatal_error("Unsupported field width: ult " + std::to_string(fw));
    149160    return CreateSExt(CreateICmpUGE(fwCast(fw, a), fwCast(fw, b)), fwVectorType(fw));
     
    158169
    159170Value * IDISA_Builder::simd_umax(unsigned fw, Value * a, Value * b) {
    160     if (fw < 8) report_fatal_error("Unsupported field width: umax " + std::to_string(fw));
     171    if (fw == 1) return simd_or(a, b);
     172    if (fw < 8) {
     173        Value * hi_rslt = simd_and(simd_himask(2*fw), simd_umax(2*fw, a, b));
     174        Value * lo_rslt = simd_umax(2*fw, simd_and(simd_lomask(2*fw), a), simd_and(simd_lomask(2*fw), b));
     175        return simd_or(hi_rslt, lo_rslt);
     176    }
    161177    Value * aVec = fwCast(fw, a);
    162178    Value * bVec = fwCast(fw, b);
     
    172188
    173189Value * IDISA_Builder::simd_umin(unsigned fw, Value * a, Value * b) {
    174     if (fw < 8) report_fatal_error("Unsupported field width: umin " + std::to_string(fw));
     190    if (fw == 1) return simd_and(a, b);
     191    if (fw < 8) {
     192        Value * hi_rslt = simd_and(simd_himask(2*fw), simd_umin(2*fw, a, b));
     193        Value * lo_rslt = simd_umin(2*fw, simd_and(simd_lomask(2*fw), a), simd_and(simd_lomask(2*fw), b));
     194        return simd_or(hi_rslt, lo_rslt);
     195    }
    175196    Value * aVec = fwCast(fw, a);
    176197    Value * bVec = fwCast(fw, b);
     
    308329    Value * pext_shift_back_amts = simd_and(simd_lomask(fieldwidth), delcounts.back());
    309330    Value * w = simd_sllv(fieldwidth, v, pext_shift_back_amts);
    310    
    311331    //
    312332    // No work through the smaller field widths.
     
    321341                    simd_sllv(fw, simd_and(w, pext_shift_back_field_mask), pext_shift_back_amts));
    322342    }
    323     return w;
     343    return CreateAnd(w, deposit_mask);
    324344}
    325345
     
    517537
    518538Value * IDISA_Builder::mvmd_extract(unsigned fw, Value * a, unsigned fieldIndex) {
    519     if (fw < 8) report_fatal_error("Unsupported field width: mvmd_extract " + std::to_string(fw));
     539    if (fw < 8) {
     540        unsigned byte_no = (fieldIndex * fw) / 8;
     541        unsigned intrabyte_shift = (fieldIndex * fw) % 8;
     542        Value * byte = CreateExtractElement(fwCast(8, a), getInt32(byte_no));
     543        return CreateTrunc(CreateLShr(byte, getInt8(intrabyte_shift)), getIntNTy(fw));
     544    }
    520545    return CreateExtractElement(fwCast(fw, a), getInt32(fieldIndex));
    521546}
    522547
    523 Value * IDISA_Builder::mvmd_insert(unsigned fw, Value * blk, Value * elt, unsigned fieldIndex) {
    524     if (fw < 8) report_fatal_error("Unsupported field width: mvmd_insert " + std::to_string(fw));
    525     return CreateInsertElement(fwCast(fw, blk), elt, getInt32(fieldIndex));
     548Value * IDISA_Builder::mvmd_insert(unsigned fw, Value * a, Value * elt, unsigned fieldIndex) {
     549    if (fw < 8) {
     550        unsigned byte_no = (fieldIndex * fw) / 8;
     551        unsigned intrabyte_shift = (fieldIndex * fw) % 8;
     552        unsigned field_mask = ((1 << fw) - 1) << intrabyte_shift;
     553        Value * byte = CreateAnd(CreateExtractElement(fwCast(8, a), getInt32(byte_no)), getInt8(0xFF &~ field_mask));
     554        byte = CreateOr(byte, CreateShl(CreateZExtOrTrunc(elt, getInt8Ty()), getInt8(intrabyte_shift)));
     555        return CreateInsertElement(fwCast(8, a), byte, getInt32(byte_no));
     556    }
     557    return CreateInsertElement(fwCast(fw, a), elt, getInt32(fieldIndex));
    526558}
    527559
Note: See TracChangeset for help on using the changeset viewer.