Changeset 6099


Ignore:
Timestamp:
Jun 17, 2018, 8:25:34 AM (4 weeks ago)
Author:
cameron
Message:

Optimization of simd_if for AVX-512 using ternary logic instruction (vpternlogd)

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

Legend:

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

    r6098 r6099  
    799799}
    800800
     801Value * IDISA_AVX512F_Builder::simd_if(unsigned fw, Value * cond, Value * a, Value * b) {
     802    if (fw == 1) {
     803        Value * ternLogicFn = Intrinsic::getDeclaration(getModule(),  Intrinsic::x86_avx512_mask_pternlog_d_512);
     804        // Form the 8-bit table for simd-if based on the bitwise values from cond, a and b.
     805        //   (cond, a, b) =  (111), (110), (101), (100), (011), (010), (001), (000)
     806        // if(cond, a, b) =    1      1      0      0      1      0      1      0    = 0xCA
     807        Constant * simd_if_mask = ConstantInt::get(getInt32Ty(), 0xCA);
     808        Constant * writemask = ConstantInt::getAllOnesValue(getInt16Ty());
     809        Value * args[5] = {fwCast(32, cond), fwCast(32, a), fwCast(32, b), simd_if_mask, writemask};
     810        Value * rslt = CreateCall(ternLogicFn, args);
     811        return rslt;
     812    }
     813    return IDISA_AVX2_Builder::simd_if(fw, cond, a, b);
     814}
    801815
    802816void IDISA_AVX512F_Builder::getAVX512Features() {
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_avx_builder.h

    r6098 r6099  
    8686    llvm::Value * mvmd_srl(unsigned fw, llvm::Value * a, llvm::Value * shift) override;
    8787    llvm::Value * mvmd_sll(unsigned fw, llvm::Value * a, llvm::Value * shift) override;
     88    llvm::Value * simd_if(unsigned fw, llvm::Value * cond, llvm::Value * a, llvm::Value * b) override;
    8889
    8990    ~IDISA_AVX512F_Builder() {
Note: See TracChangeset for help on using the changeset viewer.