[llvm-commits] [PATCH] Compress Repeated Byte Output

Chris Lattner clattner at apple.com
Fri Aug 26 16:39:22 PDT 2011


On Aug 26, 2011, at 10:48 AM, David Greene wrote:

> 
> Emit a repeated sequence of bytes using .zero.  This saves an enormous
> amount of asm file space for certain programs.
> ---

In addition to the return, please remove these two cases, which are handled below with the generic code:

+    if (CI->isZero())
+      return 0;
+    if (CI->isAllOnesValue())
+      return 0xfful;



+    uint8_t Byte = Value & 0xffull;

What's up with the ULL suffixes here and UL elsewhere?  Please use capital suffixes if you want to keep them.  I'd recommend just replacing this with uint8_t(Value) which is more explicit.

+    if (Size == 1)
+      return Byte;

Please remove this, it isn't doing anything.

Your ConstantInt handling code still doesn't handle i11's.  You need to ensure that we have a multiple of 8 bits and a power of 2 (to avoid tail padding being ignored).

+    return Byte;
+  }
+  else if 

No need for the else.

+  else if (const ConstantArray *CA = dyn_cast<ConstantArray>(V)) {
+    // Make sure all array elements are sequences of the same repeated
+    // byte.
+    int Byte = -1;
+    for (int i = 0, e = CA->getNumOperands(); i != e; ++i) {

This is awkward.  Just peel off one iteration:

if (CA->getNumElements() == 0) return -1;

int Byte = isRepeatedByteSequence(CA->getOperand(0), TM);
if (Byte == -1) return -1;

for (i = 1, ...

-Chris



More information about the llvm-commits mailing list