This is an archive of the discontinued LLVM Phabricator instance.

Implement load to store => memcpy in MemCpyOpt for aggregates
ClosedPublic

Authored by deadalnix on Jan 5 2016, 10:29 AM.

Details

Summary

Most of the tool chain is able to optimize scalar and memcpy like operation effisciently while it isn't that good with aggregates. In order to improve the support of aggregate, we try to change aggregate manipulation into either scalar or memcpy like ones whenever possible without loosing informations.

This is one such opportunity.

Diff Detail

Repository
rL LLVM

Event Timeline

deadalnix updated this revision to Diff 44022.Jan 5 2016, 10:29 AM
deadalnix retitled this revision from to Implement load to store => memcpy in MemCpyOpt for aggregates.
deadalnix updated this object.
deadalnix added a subscriber: llvm-commits.
mehdi_amini added inline comments.
lib/Transforms/Scalar/MemCpyOptimizer.cpp
528 ↗(On Diff #44022)

one line comment this loop and AI

533 ↗(On Diff #44022)

not sure what you mean by " If the dest of the second might alias the source of the first", this sentence seems confusing to me. Is there more than // If the load and the store alias, we have to use a memmove instead of a memcpy. ?

majnemer added inline comments.
lib/Transforms/Scalar/MemCpyOptimizer.cpp
539 ↗(On Diff #44022)

This should be a uint64_t.

deadalnix added inline comments.Jan 5 2016, 11:20 AM
lib/Transforms/Scalar/MemCpyOptimizer.cpp
533 ↗(On Diff #44022)

If the memory location we load from and store to can somehow alias, we need to use memmove to preserve semantic. If they do not, we can use memcpy.

deadalnix updated this revision to Diff 44033.Jan 5 2016, 11:39 AM

Add explainations in comments.

mehdi_amini accepted this revision.Jan 5 2016, 11:58 AM
mehdi_amini added a reviewer: mehdi_amini.

LGTM with a typo to fix

lib/Transforms/Scalar/MemCpyOptimizer.cpp
565 ↗(On Diff #44033)

s/iterrator/iterator/

This revision is now accepted and ready to land.Jan 5 2016, 11:58 AM
spatel added inline comments.Jan 5 2016, 12:05 PM
lib/Transforms/Scalar/MemCpyOptimizer.cpp
484 ↗(On Diff #44033)

"findCommonAlignment" (remove extra 'e')

486 ↗(On Diff #44033)

Variable names should be capitalized.

510 ↗(On Diff #44033)

tore -> store

deadalnix updated this revision to Diff 44040.Jan 5 2016, 12:07 PM
deadalnix edited edge metadata.

Fix typos and capitalize variables

This revision was automatically updated to reflect the committed changes.