This is an archive of the discontinued LLVM Phabricator instance.

[X86] Disable mul -> shl + lea combine when compiling for minsize
ClosedPublic

Authored by mkuper on Aug 10 2015, 7:36 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

mkuper updated this revision to Diff 31667.Aug 10 2015, 7:36 AM
mkuper retitled this revision from to [X86] Disable mul -> shl + lea combine when compiling for minsize.
mkuper updated this object.
mkuper added reviewers: spatel, RKSimon.
mkuper added a subscriber: llvm-commits.
RKSimon edited edge metadata.Aug 10 2015, 9:07 AM

Slightly off at a tangent: are we ensuring that we keep to the small (8-bit immediate) imul implementation when possible? I seem to recall there's been a problem with unnecessary 32-bit immediate imul instructions causing code bloat.

spatel added inline comments.Aug 10 2015, 9:20 AM
lib/Target/X86/X86ISelLowering.cpp
23521 ↗(On Diff #31667)

Missing period.

test/CodeGen/X86/imul.ll
112–119 ↗(On Diff #31667)

Does this test change with the patch? Is there a reason i386 should be different than x86-64?

Thanks, Simon, Sanjay.

Simon:
It should be all right now. E.g.:

echo imull $12, %eax, %eax | llvm-mc --show-encoding

.text
imull   $12, %eax, %eax         # encoding: [0x6b,0xc0,0x0c]

The issues you were seeing were most likely fixed in r241152.

test/CodeGen/X86/imul.ll
112–119 ↗(On Diff #31667)

This is just a copy of a test from above, but with minsize added. I wanted to verify that we still produce a single shift/lea (as opposed to a sequence with > 1 instructions) even under minsize.
Do you think this is redundant?

spatel added inline comments.Aug 11 2015, 7:07 AM
test/CodeGen/X86/imul.ll
112–119 ↗(On Diff #31667)

Ah, I didn't notice the earlier test. I got tired of running into the FIXMEs that I added with r243994, so I've been adding minsize tests myself. In some cases, it has exposed functionality with no regression tests, so I like having the test.

Not a problem then, although I'm still curious why this is different for 32-bit. The answer may be related to that "But why?!" comment above. :)

spatel accepted this revision.Aug 11 2015, 7:11 AM
spatel edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Aug 11 2015, 7:11 AM
This revision was automatically updated to reflect the committed changes.