[LLVMdev] Fwd: How to force the creation of arrays with zeroes?

Stepan Dyatkovskiy STPWORLD at narod.ru
Sat Jan 21 11:25:44 PST 2012


To Anton:
>>  In these 2 particular cases the changes of the code size can
>>  definitely be neglected. Even more, in SCCP the use of CAZ is a
>>  performance win, since we do not have to check at all operands are
>>  zero, we already (!) know this.
Little fragment from SCCP.cpp, lines 413-418:
      ...
      else if (ConstantStruct *CS = dyn_cast<ConstantStruct>(C))
        LV.markConstant(CS->getOperand(i));      // Constants are constant.
      else if (isa<ConstantAggregateZero>(C)) {
        Type *FieldTy = cast<StructType>(V->getType())->getElementType(i);
        LV.markConstant(Constant::getNullValue(FieldTy));                                
      } else
      ...
I couldn't found that performance wins here. We can just hide these branches either inside the improved implementation of ConstantVector/Array/Struct or inside the wraper. 

I agree with Duncan reasoning. We can just to store single zero item and flag. This changes also allows make code cleaner. 
> if a constant array has many repeated elements, maybe the
> array could be stored in a compressed form.
Did you mean reducing actual number of operands? As I found all repeated values instead a pointers to the same Value in LLVMContext (or I missed something?).

-Stepan.



More information about the llvm-dev mailing list