This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen][ExpandMemcmp][NFC] Allow memcmp to expand to vector loads, part 1.
ClosedPublic

Authored by courbet on Oct 3 2017, 5:46 AM.

Details

Summary

Refactor ExpandMemcmp:

  • Stop duplicating the logic for computation of the sequence of loads to generate (thsi was done in three different places), this is now done only once in MemCmpExpansion::MemCmpExpansion().
  • Add a FIXME to expose a bug with the computation of the number of loads when not all sizes are loadable. For example, on X86-32 + SSE, possible loads are {16,4,2,1} bytes. The current code considers that all loads starting at MaxLoadSize are possible. This is not an issue right now as vector loads are not enabled, so I'm not fixing the issue here to keep the change as small as possible. I'm going to address this in a subsequent revision, where I enable vector loads.

See https://bugs.llvm.org/show_bug.cgi?id=34887

Diff Detail

Repository
rL LLVM

Event Timeline

courbet created this revision.Oct 3 2017, 5:46 AM
courbet updated this revision to Diff 118212.Oct 9 2017, 8:51 AM

Refactor MemCmpExpansion.

courbet retitled this revision from [CodeGen][ExpandMemcmp] Allow memcmp to expand to vector loads. to [CodeGen][ExpandMemcmp][NFC] Allow memcmp to expand to vector loads, part 1..Oct 9 2017, 9:12 AM
courbet edited the summary of this revision. (Show Details)
courbet edited the summary of this revision. (Show Details)
courbet updated this revision to Diff 118215.Oct 9 2017, 9:14 AM
  • better comments
courbet edited the summary of this revision. (Show Details)Oct 9 2017, 9:17 AM
courbet updated this revision to Diff 118216.Oct 9 2017, 9:17 AM
courbet edited the summary of this revision. (Show Details)
  • clang-format

Does this just not have reviewers because it isn't ready for review yet?

Yes, I realized this could actually be split in two smaller revisions.

courbet updated this revision to Diff 118323.Oct 10 2017, 12:53 AM

Split the revision in two smaller ones.

courbet edited the summary of this revision. (Show Details)Oct 10 2017, 12:59 AM
courbet added reviewers: spatel, nemanjai.
courbet added a subscriber: llvm-commits.

Ping ? Even though this does not not have any functional changes, I'd like it to have a review since I'm going to base vector expansion on this.

spatel edited edge metadata.Oct 20 2017, 9:51 AM

Sorry for the delay. I've made a few inline suggestions. I'm still going through the diffs to try to understand, but if you can reply/update on those, I think it will make it easier.

lib/CodeGen/CodeGenPrepare.cpp
1731 ↗(On Diff #118323)

"Entry" / "Entries" is vague - "LoadEntry" / "LoadSequence"?

1792–1794 ↗(On Diff #118323)

This used to have log2 rather than a loop, right? I think it's easier to read like this, but I'd keep the comment to explain:
// Scale the max size down if the target can load more bytes than we need.

1912–1921 ↗(On Diff #118323)

That's a tough "line" of code - split up with some local variables to make this more readable.

courbet updated this revision to Diff 119814.Oct 23 2017, 12:25 AM
courbet marked 2 inline comments as done.
  • Address review comments.

Thanks, My turn to apologize for the delay, I was off for the week-end.

lib/CodeGen/CodeGenPrepare.cpp
1792–1794 ↗(On Diff #118323)

Yes, you're right.

1912–1921 ↗(On Diff #118323)

...and the max_element is actually the same as MaxLoadSize. Thanks for the catch.

spatel accepted this revision.Oct 23 2017, 6:34 AM

LGTM.

This revision is now accepted and ready to land.Oct 23 2017, 6:34 AM

Thanks for the review.

This revision was automatically updated to reflect the committed changes.