[PATCH] Change MachineOperand OpKind to a bitfield
peter_cooper at apple.com
Mon Apr 20 16:10:28 PDT 2015
MachineOperand::OpKind is an unsigned char, followed by 24-bits of bitfields. clang is able to make all of that take 32-bits of space, but it generates pretty nasty code to do so.
OpKind itself is loaded and stored as an i8 and so gets very nice IR. However, loading an entry from one of the bitfields results in a load of an i24, then masking operations. Given that i24 isn’t legal, the legalizer goes to great lengths to make this work, typically splitting it in to i8 and i16 operations.
I’m not sure if clang is allowed to fold the bitfield operations in to OpKind and do everything as i32 (what if OpKind was volatile for example). So instead here’s a patch to change OpKind to an i8. I’m also not sure if llvm’s optimizer could be taught this, although thats some pretty scary code to have to write.
I’ve verified that this generates i32 load/store for all reads/writes of all the fields. So OpKind itself results in a small increase in code size to be read (an i32 load followed by a trunc, usually folded away in ISel), but the reads of the other fields are much better.
Overall this saves 16KB on the size of the llc binary.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 508 bytes
Desc: not available
More information about the llvm-commits