Changeset 4828
 Timestamp:
 Oct 9, 2015, 11:59:50 AM (4 years ago)
 Location:
 icGREP/icgrepdevel/icgrep/pablo
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

icGREP/icgrepdevel/icgrep/pablo/carry_manager.cpp
r4827 r4828 367 367 } 368 368 369 Value* CarryManager::genShiftLeft64(Value* e) {370 Value* i128_val = mBuilder>CreateBitCast(e, mBuilder>getIntNTy(mBITBLOCK_WIDTH));371 return mBuilder>CreateBitCast(mBuilder>CreateShl(i128_val, 64), mBitBlockType);372 }373 374 369 Value * CarryManager::addCarryInCarryOut(int localIndex, Value* e1, Value* e2) { 375 #if (mBITBLOCK_WIDTH == 128) 376 Value * carryq_value = getCarryOpCarryIn(localIndex);377 //calculate carry through logical ops378 Value* carrygen = mBuilder>CreateAnd(e1, e2, "carrygen");379 Value* carryprop = mBuilder>CreateOr(e1, e2, "carryprop");380 Value* digitsum = mBuilder>CreateAdd(e1, e2, "digitsum");381 Value* partial = mBuilder>CreateAdd(digitsum, carryq_value, "partial");382 Value* digitcarry = mBuilder>CreateOr(carrygen, mBuilder>CreateAnd(carryprop, mBuilder>CreateNot(partial)));383 Value* mid_carry_in = genShiftLeft64(mBuilder>CreateLShr(digitcarry, 63));384 Value* sum = mBuilder>CreateAdd(partial, mBuilder>CreateBitCast(mid_carry_in, mBitBlockType), "sum");385 Value* carry_out_strm = mBuilder>CreateOr(carrygen, mBuilder>CreateAnd(carryprop, mBuilder>CreateNot(sum)));386 setCarryOpCarryOut(localIndex, carry_out_strm);387 return sum;388 #else 389 //mBITBLOCK_WIDTH == 256, there is no other implementation390 Value * carryq_value = getCarryOpCarryIn(localIndex);391 Value* carrygen = mBuilder>CreateAnd(e1, e2, "carrygen");392 Value* carryprop = mBuilder>CreateOr(e1, e2, "carryprop");393 Value * sum = iBuilder>simd_add(mBITBLOCK_WIDTH, iBuilder>simd_add(mBITBLOCK_WIDTH, e1, e2), carryq_value);394 Value* carry_out_strm = mBuilder>CreateOr(carrygen, mBuilder>CreateAnd(carryprop, mBuilder>CreateNot(sum)));395 setCarryOpCarryOut(localIndex, carry_out_strm);396 return sum;397 #endif 370 if (mBITBLOCK_WIDTH == 128) { 371 Value * carryq_value = getCarryOpCarryIn(localIndex); 372 //calculate carry through logical ops 373 Value* carrygen = mBuilder>CreateAnd(e1, e2, "carrygen"); 374 Value* carryprop = mBuilder>CreateOr(e1, e2, "carryprop"); 375 Value* digitsum = iBuilder>simd_add(64, e1, e2); 376 Value* partial = iBuilder>simd_add(64, digitsum, carryq_value); 377 Value* digitcarry = mBuilder>CreateOr(carrygen, mBuilder>CreateAnd(carryprop, mBuilder>CreateNot(partial))); 378 Value* mid_carry_in = iBuilder>simd_slli(128, mBuilder>CreateLShr(digitcarry, 63), 64); 379 Value* sum = iBuilder>simd_add(64, partial, mBuilder>CreateBitCast(mid_carry_in, mBitBlockType)); 380 Value* carry_out_strm = mBuilder>CreateOr(carrygen, mBuilder>CreateAnd(carryprop, mBuilder>CreateNot(sum))); 381 setCarryOpCarryOut(localIndex, carry_out_strm); 382 return sum; 383 } 384 else { 385 Value * carryq_value = getCarryOpCarryIn(localIndex); 386 Value* carrygen = mBuilder>CreateAnd(e1, e2, "carrygen"); 387 Value* carryprop = mBuilder>CreateOr(e1, e2, "carryprop"); 388 Value * sum = iBuilder>simd_add(mBITBLOCK_WIDTH, iBuilder>simd_add(mBITBLOCK_WIDTH, e1, e2), carryq_value); 389 Value* carry_out_strm = mBuilder>CreateOr(carrygen, mBuilder>CreateAnd(carryprop, mBuilder>CreateNot(sum))); 390 setCarryOpCarryOut(localIndex, carry_out_strm); 391 return sum; 392 } 398 393 } 399 394 … … 428 423 Value* result_value; 429 424 430 #if (mBITBLOCK_WIDTH == 128) && !defined(USE_LONG_INTEGER_SHIFT) 431 Value * ahead64 = iBuilder>mvmd_dslli(64, carry_in, strm, 1);432 result_value = mBuilder>CreateOr(iBuilder>simd_srli(64, ahead64, 63), iBuilder>simd_slli(64, strm, 1));433 #else 434 Value* advanceq_longint = mBuilder>CreateBitCast(carry_in, mBuilder>getIntNTy(mBITBLOCK_WIDTH));435 Value* strm_longint = mBuilder>CreateBitCast(strm, mBuilder>getIntNTy(mBITBLOCK_WIDTH));436 Value* adv_longint = mBuilder>CreateOr(mBuilder>CreateShl(strm_longint, 1), mBuilder>CreateLShr(advanceq_longint, mBITBLOCK_WIDTH  1), "advance");437 result_value = mBuilder>CreateBitCast(adv_longint, mBitBlockType);438 439 #endif 425 if (mBITBLOCK_WIDTH == 128) { 426 Value * ahead64 = iBuilder>mvmd_dslli(64, carry_in, strm, 1); 427 result_value = mBuilder>CreateOr(iBuilder>simd_srli(64, ahead64, 63), iBuilder>simd_slli(64, strm, 1)); 428 } 429 else { 430 Value* advanceq_longint = mBuilder>CreateBitCast(carry_in, mBuilder>getIntNTy(mBITBLOCK_WIDTH)); 431 Value* strm_longint = mBuilder>CreateBitCast(strm, mBuilder>getIntNTy(mBITBLOCK_WIDTH)); 432 Value* adv_longint = mBuilder>CreateOr(mBuilder>CreateShl(strm_longint, 1), mBuilder>CreateLShr(advanceq_longint, mBITBLOCK_WIDTH  1), "advance"); 433 result_value = mBuilder>CreateBitCast(adv_longint, mBitBlockType); 434 } 440 435 return result_value; 441 436 } 
icGREP/icgrepdevel/icgrep/pablo/carry_manager.h
r4827 r4828 164 164 void extractAndSaveCarryOutBits(Value * strm, unsigned carryBit_lo, unsigned carryBitCount); 165 165 Value * pack2bitblock(Value * pack); 166 Value* genShiftLeft64(Value* e);167 166 168 167
Note: See TracChangeset
for help on using the changeset viewer.