This is an archive of the discontinued LLVM Phabricator instance.

[X86] Use "and $0" and "orl $-1" to store 0 and -1 when optimizing for minsize
ClosedPublic

Authored by hans on Mar 22 2016, 1:35 PM.

Details

Summary

64-bit, 32-bit and 16-bit move-immediate instructions are 7, 6, and 5 bytes, respectively, whereas 8-bit and/or is only three bytes.

Since these instructions imply an additional memory read (which the CPU could elide, but we don't think it does), restrict these patterns to minsize functions.

Diff Detail

Repository
rL LLVM

Event Timeline

hans updated this revision to Diff 51333.Mar 22 2016, 1:35 PM
hans retitled this revision from to [X86] Use "and $0" and "orl $-1" to store 0 and -1 when optimizing for minsize.
hans updated this object.
hans added reviewers: DavidKreitzer, zansari.
hans added subscribers: llvm-commits, joerg.
DavidKreitzer edited edge metadata.Mar 25 2016, 6:11 AM

Other than a minor suggestion on the test name, LGTM.

test/CodeGen/X86/store-zero.ll
1 ↗(On Diff #51333)

You might want to change the name of the test, since it is testing both 0 and -1.

hans added a comment.Mar 25 2016, 11:16 AM

I ran 64-bit bootstrap builds at -Oz of clang with and without my change and measured a binary size reduction of 139264 bytes (0.20 %).

test/CodeGen/X86/store-zero.ll
1 ↗(On Diff #51333)

Good point, renamed.

This revision was automatically updated to reflect the committed changes.