Ignore:
Timestamp:
Oct 19, 2014, 1:43:18 PM (5 years ago)
Author:
nmedfort
Message:

Couple minor changes to reduce some LLVM optimization work.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r4249 r4250  
    8888, mCarryQueueSize(0)
    8989, mZeroInitializer(ConstantAggregateZero::get(mXi64Vect))
    90 , mAllOneInitializer(ConstantVector::getAllOnesValue(mXi64Vect))
     90, mOneInitializer(ConstantVector::getAllOnesValue(mXi64Vect))
    9191, mFuncTy_0(nullptr)
    9292, mFunc_process_block(nullptr)
     
    153153
    154154    Function::arg_iterator args = mFunc_process_block->arg_begin();
    155     Value* ptr_basis_bits = args++;
    156     ptr_basis_bits->setName("basis_bits");
     155    mBasisBitsAddr = args++;
     156    mBasisBitsAddr->setName("basis_bits");
    157157    mptr_carry_q = args++;
    158158    mptr_carry_q->setName("carry_q");
     
    165165
    166166    //The basis bits structure
    167     mBasisBitsAddr = new AllocaInst(mBasisBitsInputPtr, "basis_bits.addr", mBasicBlock);
    168     new StoreInst(ptr_basis_bits, mBasisBitsAddr, false, mBasicBlock);
    169167    for (unsigned i = 0; i < mBits; ++i) {
    170168        IRBuilder<> b(mBasicBlock);
    171         Value* basisBit = b.CreateLoad(mBasisBitsAddr);
    172169        Value* indices[] = {b.getInt64(0), b.getInt32(i)};
    173170        const std::string name = mBasisBitVars[i]->getName();
    174         Value* basis_bits_struct_GEP = b.CreateGEP(basisBit, indices, name);
    175         mMarkerMap.insert(make_pair(name, basis_bits_struct_GEP));
     171        mMarkerMap.insert(make_pair(name, b.CreateGEP(mBasisBitsAddr, indices, name)));
    176172    }
    177173    mPtr_output_addr = new AllocaInst(mOutputPtr, "output.addr", mBasicBlock);
     
    479475
    480476Value* PabloCompiler::GetMarker(const std::string & name)
    481 {
    482     IRBuilder<> b(mBasicBlock);
     477{   
    483478    auto itr = mMarkerMap.find(name);
    484479    if (itr == mMarkerMap.end()) {
    485         Value* ptr = b.CreateAlloca(mXi64Vect);
    486         b.CreateStore(mZeroInitializer, ptr);
    487         itr = mMarkerMap.insert(make_pair(name, ptr)).first;
     480        IRBuilder<> b(mBasicBlock);
     481        itr = mMarkerMap.insert(make_pair(name, b.CreateAlloca(mXi64Vect))).first;
    488482    }
    489483    return itr->second;
    490484}
    491485
    492 void PabloCompiler::SetReturnMarker(Value * marker, const unsigned output_idx)
     486void PabloCompiler::SetReturnMarker(Value * marker, const unsigned index)
    493487{
    494488    IRBuilder<> b(mBasicBlock);
    495489    Value* marker_bitblock = b.CreateLoad(marker);
    496490    Value* output_struct = b.CreateLoad(mPtr_output_addr);
    497     Value* output_indices[] = {b.getInt64(0), b.getInt32(output_idx)};
     491    Value* output_indices[] = {b.getInt64(0), b.getInt32(index)};
    498492    Value* output_struct_GEP = b.CreateGEP(output_struct, output_indices);
    499493    b.CreateStore(marker_bitblock, output_struct_GEP);
     
    632626    if (isa<Ones>(expr))
    633627    {
    634         Value* ptr_all = b.CreateAlloca(mXi64Vect);
    635         b.CreateStore(mAllOneInitializer, ptr_all);
    636         retVal = b.CreateLoad(ptr_all);
     628        retVal = mOneInitializer;
    637629    }
    638630    else if (isa<Zeroes>(expr))
    639631    {
    640         Value* ptr_all = b.CreateAlloca(mXi64Vect);
    641         b.CreateStore(mZeroInitializer, ptr_all);
    642         retVal = b.CreateLoad(ptr_all);
     632        retVal = mZeroInitializer;
    643633    }
    644634    else if (const Call* call = dyn_cast<Call>(expr))
     
    651641                throw std::runtime_error("Unexpected error locating static function for \"" + call->getCallee() + "\"");
    652642            }
    653             Value* basis_bits_struct = b.CreateLoad(mBasisBitsAddr);
    654             Value* unicode_category = b.CreateCall(ci->second, basis_bits_struct);
    655             Value* ptr = b.CreateAlloca(mXi64Vect);
     643            Value * unicode_category = b.CreateCall(ci->second, mBasisBitsAddr);
     644            Value * ptr = b.CreateAlloca(mXi64Vect);
    656645            b.CreateStore(unicode_category, ptr);
    657646            mi = mMarkerMap.insert(std::make_pair(call->getCallee(), ptr)).first;
     
    681670    {
    682671        Value* expr_value = compileExpression(pablo_not->getExpr());
    683         retVal = b.CreateXor(expr_value, mAllOneInitializer, "not");
     672        retVal = b.CreateXor(expr_value, mOneInitializer, "not");
    684673    }
    685674    else if (const Advance * adv = dyn_cast<Advance>(expr))
     
    802791Value* PabloCompiler::genNot(Value* e, const Twine &namehint) {
    803792    IRBuilder<> b(mBasicBlock);
    804     return b.CreateXor(e, mAllOneInitializer, namehint);
     793    return b.CreateXor(e, mOneInitializer, namehint);
    805794}
    806795
Note: See TracChangeset for help on using the changeset viewer.