This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Support differing src and dst alignments for memcpy/memmove
AbandonedPublic

Authored by nikic on Nov 13 2018, 6:39 AM.

Details

Reviewers
None
Summary

The IR layer has already been switched to support different source and destination alignments for memcpy and memmove. However, this information is currently being discarded during SelectionDAG construction.

This patch pulls the different alignments through SelectionDAG and target lowering. The main changes are:

  • SelectionDAG::getMemcpy and SelectionDAG::getMemmove now take separate DstAlign and SrcAlign arguments.
  • EmitTargetCodeForMemcpy and EmitTargetCodeForMemmove now take separate DstAlign and SrcAlign arguments.
  • Call-sites of getMemcpy are adjusted: These are usually either handling of byval arguments, or va_copy. In both cases I'm using the same source and destination alignment.
  • Reviewed definitions of getOptimalMemOpType to make sure they treat the DstAlign and SrcAlign arguments correctly. These arguments were already separate previously, but there was a guarantee that always SrcAlign >= DstAlign (or zero). This guarantee no longer exists, so some additional checks need to be added.
  • Added a test that shows mixed use of movaps/movups on X86 after this change. Previously all instructions were movups in the test.

Diff Detail

Event Timeline

nikic created this revision.Nov 13 2018, 6:39 AM
nikic abandoned this revision.Mar 15 2019, 3:19 PM

Unlikely that I'll try to push this one through.

Herald added a project: Restricted Project. · View Herald TranscriptMar 15 2019, 3:19 PM