[llvm-commits] [PATCH] Compress Repeated Byte Output
Chris Lattner
clattner at apple.com
Thu Aug 25 15:34:08 PDT 2011
On Aug 25, 2011, at 1:43 PM, David Greene wrote:
>
> Emit a repeated sequence of bytes using .zero. This saves an enormous
> amount of asm file space for certain programs.
> ---
>
> This patch fixed a bunch of problems we saw related to asm output file size.
> Please review. Thanks!
Looks good with a few changes:
+static bool isRepeatedByteSequence(const ConstantInt *CI, TargetMachine &TM) {
This needs a doxygen comment, also please change it to be something like:
static int isRepeatedByteSequence(const Value *V, TargetMachine &TM) {
and have it return 0-255 for success and -1 for failure. It should handle the non-ConstantInt case as well. You could even generalize this predicate to handle structs and subarrays if you feel ambitious (but as a follow-on patch).
+ if (CI->isZero() ||
+ CI->isAllOnesValue() ||
+ TM.getTargetData()->getTypeAllocSize(CI->getType()) == 1)
+ return true;
+
+ unsigned Bytes = TM.getTargetData()->getTypeAllocSize(CI->getType());
Please don't call getTypeAllocSize twice, use:
+ if (CI->isZero() || CI->isAllOnesValue())
return true;
+ unsigned Bytes = TM.getTargetData()->getTypeAllocSize(CI->getType());
if (Bytes == 1) return true;
...
+ uint64_t Value = CI->getZExtValue();
This will abort for int128_t, please check that the bitwidth of CI is <= 64 bits and a multiple of 8 bits.
Please resend with this changes, thanks!
-Chris
More information about the llvm-commits
mailing list