This is an archive of the discontinued LLVM Phabricator instance.

[AArch64]Redundant store instructions should be removed as dead code
ClosedPublic

Authored by David.Xu on Sep 23 2014, 12:01 AM.

Details

Summary

If there is a store followed by a store with the same value to the same location, then the store is dead/noop. It can be removed.

This problem is found in spec2006-197.parser.

For example,
stur w10, [x11, #-4]
stur w10, [x11, #-4]
Then one of the two stur instructions can be removed.

Diff Detail

Event Timeline

David.Xu updated this revision to Diff 13969.Sep 23 2014, 12:01 AM
David.Xu retitled this revision from to [AArch64]Redundant store instructions should be removed as dead code.
David.Xu updated this object.
David.Xu edited the test plan for this revision. (Show Details)
David.Xu added reviewers: t.p.northover, Jiangning.
David.Xu added subscribers: mcrosier, Unknown Object (MLST).
jmolloy accepted this revision.Sep 24 2014, 2:47 AM
jmolloy added a reviewer: jmolloy.
jmolloy added a subscriber: jmolloy.

Hi David,

Thanks for working on this. This patch looks good to me, thanks!

Cheers,

James

This revision is now accepted and ready to land.Sep 24 2014, 2:47 AM

LGTM, with a few comments.

lib/CodeGen/SelectionDAG/DAGCombiner.cpp
9797

What if the 2nd store is a larger value type? Wouldn't the first store still be dead?

(Just a comment that, if true, doesn't need to be addresses in this patch.)

9800

Just move this line up to maximize horizontal space and reduce vertical space (i.e., "ST1->isunindexed() && !ST1->isVolatie() &&").

9801

"between the two stores", perhaps.

Line 9800 can't be moved up to maximize horizontal space and reduce vertical space, because clang-formate does not allow this. When it is moved up, it will be moved down after executing "git clang-formate" command.

jmolloy closed this revision.Sep 27 2014, 10:13 AM

Hi,

As David has now finished his internship at ARM, I took the liberty of committing this after updating it for review feedback.

  • Vertical space maximised as requested.
  • reachesChainWithoutSideEffects() is not required, as it is guaranteed that the two chains are both stores with no intervening chains.

Committed in r218569.

Cheers,

James