This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Use sub for negative offset load/store in thumb1
ClosedPublic

Authored by dmgreen on Jan 23 2019, 2:48 PM.

Details

Summary

This attempts to optimise negative values used in load/store operands
a little. We currently try to selct them as rr, materialising the
negative constant using a MOV/MVN pair. This instead selects ri with
an immediate of 0, forcing the add node to become a simpler sub.

The ldrsb and ldrsh tests here are not really better, but not worse either.
It will depend upon whether the constant or the add havee multiple uses.
It appears to be fairly common for an address to be used, and stored
somewhere at the same time.

Diff Detail

Repository
rL LLVM

Event Timeline

dmgreen created this revision.Jan 23 2019, 2:48 PM

Can you give an example where this transform helps for ldrsb/ldrsh?

lib/Target/ARM/ARMISelDAGToDAG.cpp
1043 ↗(On Diff #183184)

Does the actual value matter here? If we're going to generate a constant pool load, this doesn't seem profitable.

dmgreen updated this revision to Diff 183846.Jan 28 2019, 6:51 AM

I've removed the ldrsh/ldrsb and made sure the value is a legal for a sub. This may or may not be what you meant, let me know.

efriedma accepted this revision.Jan 28 2019, 3:28 PM

LGTM

lib/Target/ARM/ARMInstrThumb.td
190 ↗(On Diff #183846)

Maybe add a brief comment here noting this is separate because we use different heuristics for ldrsb/ldrsh.

This revision is now accepted and ready to land.Jan 28 2019, 3:28 PM
This revision was automatically updated to reflect the committed changes.