This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Shrink post-indexed LDR and STR to LDM/STM
ClosedPublic

Authored by jmolloy on May 26 2016, 2:28 PM.

Details

Summary

A Thumb-2 post-indexed LDR instruction such as:

ldr.w r0, [r1], #4

Can be rewritten as:

ldm.n r1!, {r0}

LDMs can be more expensive than LDRs on some cores, so this has been enabled only in minsize mode. This is a trick learned from ARM Compiler 5 ("armcc").

Diff Detail

Repository
rL LLVM

Event Timeline

jmolloy updated this revision to Diff 58697.May 26 2016, 2:28 PM
jmolloy retitled this revision from to [ARM] Shrink post-indexed LDR and STR to LDM/STM.
jmolloy updated this object.
jmolloy added reviewers: mcrosier, t.p.northover.
jmolloy set the repository for this revision to rL LLVM.
jmolloy added a subscriber: llvm-commits.
rovka added a subscriber: rovka.Jun 1 2016, 6:08 AM
rovka added inline comments.
test/CodeGen/ARM/t2-shrink-ldrpost.ll
4

Can you use armv7m + mthumb instead?

10

I think it would be a good idea to add a test case without minsize, to make sure it doesn't trigger there.

rovka added inline comments.Jun 1 2016, 7:30 AM
lib/Target/ARM/Thumb2SizeReduction.cpp
464

Shouldn't you also update the statistics here (++NumLdSts)?

t.p.northover added inline comments.Jun 1 2016, 9:46 AM
test/CodeGen/ARM/t2-shrink-ldrpost.ll
4

I think -mthumb is a Clang option only. The distinction is via triples at the LLVM level.

rovka added inline comments.Jun 2 2016, 1:55 AM
test/CodeGen/ARM/t2-shrink-ldrpost.ll
4

You're right, clang armv7m + mthumb generates a thumbv7m triple in LLVM. I didn't know that, sorry.

rovka accepted this revision.Jun 7 2016, 4:59 AM
rovka added a reviewer: rovka.

LGTM with the remaining nits (statistics and test without minsize).

This revision is now accepted and ready to land.Jun 7 2016, 4:59 AM

Thanks! committed with your suggested changes in r272002.

mcrosier closed this revision.Jun 7 2016, 6:58 AM