This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Unify handling of atomic memtransfer with non-atomic memtransfer
ClosedPublic

Authored by dneilson on May 9 2018, 12:13 PM.

Details

Summary

This change reworks the handling of atomic memcpy within the instcombine pass.
Previously, a constant length atomic memcpy would be lowered into loads & stores
as long as no more than 16 load/store pairs are created. This is quite different
from the lowering done for a non-atomic memcpy; which only ever lowers into a single
load/store pair of no more than 8 bytes. Larger constant-sized memcpy calls are
expanded to load/stores in later passes, such as SelectionDAG lowering.

In this change the behaviour for atomic memcpy is unified with non-atomic memcpy;
atomic memcpy is now treated in the same was as non-atomic memcpy has always been.
We leave it to later passes to lower longer-length atomic memcpy calls.

Due to the structure of the pass's handling of memtransfer intrinsics, this change
also gives us handling of atomic memmove that we did not previously have.

Diff Detail

Repository
rL LLVM

Event Timeline

dneilson created this revision.May 9 2018, 12:13 PM
dneilson planned changes to this revision.May 9 2018, 12:16 PM
dneilson added inline comments.
lib/Transforms/InstCombine/InstCombineCalls.cpp
130 ↗(On Diff #145982)

This is wrong. The length of an atomic memtransfer is in bytes, so there is no need to multiply by the element size.

dneilson updated this revision to Diff 145987.May 9 2018, 12:41 PM
  • Don't multiply length by element size for atomic memtransfer intrinsics.
  • Add tests to show proper behaviour in this case.
reames accepted this revision.May 10 2018, 3:00 PM
reames added a subscriber: reames.

LGTM

This revision is now accepted and ready to land.May 10 2018, 3:00 PM
This revision was automatically updated to reflect the committed changes.
llvm/trunk/lib/Transforms/InstCombine/InstCombineInternal.h