This is an archive of the discontinued LLVM Phabricator instance.

Remove unused code
ClosedPublic

Authored by hiraditya on Nov 22 2016, 1:38 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

hiraditya updated this revision to Diff 78935.Nov 22 2016, 1:38 PM
hiraditya retitled this revision from to Hoist redundant load.
hiraditya updated this object.
hiraditya added reviewers: EricWF, mclow.lists.
hiraditya added a subscriber: cfe-commits.
sebpop added a subscriber: sebpop.Nov 28 2016, 10:08 AM

Let's also add a testcase and show the performance improvement.

mclow.lists edited edge metadata.Nov 28 2016, 10:46 AM

/me wonders what the perf difference when _LIBCPP_UNROLL_LOOPS is defined or not.

I think this (_LIBCPP_UNROLL_LOOPS) falls squarely into Chandler's request that we complain to him when the compiler generates sub-optimal code, instead of doing things like manually unrolling loops.

__search is the only place where _LIBCPP_UNROLL_LOOPS is currently used.

/me wonders what the perf difference when _LIBCPP_UNROLL_LOOPS is defined or not.

I think this (_LIBCPP_UNROLL_LOOPS) falls squarely into Chandler's request that we complain to him when the compiler generates sub-optimal code, instead of doing things like manually unrolling loops.

I think we should remove all the code in the ifdef: it looks to me like this code was left in from a previous "experiment", as it never gets executed unless one compiles the code with -D_LIBCPP_UNROLL_LOOPS, which seems wrong. Let's push this cleanup in a separate commit.

There are no uses of _LIBCPP_UNROLL_LOOPS in LLVM (other than the ones in <algorithm>.

Googling for _LIBCPP_UNROLL_LOOPS on github finds the ones in libc++, and no others.
I think I'll just take it out, and see what happens.

@mclow.lists
I can remove this and update this patch with the load hoisted, if this is okay.

hiraditya updated this revision to Diff 79463.Nov 28 2016, 2:55 PM
hiraditya edited edge metadata.

Removed unused code.

mclow.lists accepted this revision.Nov 28 2016, 5:57 PM
mclow.lists edited edge metadata.

This looks fine to me - though I wonder if the compiler can hoist *__first2 w/o us helping it.

This revision is now accepted and ready to land.Nov 28 2016, 5:57 PM
mclow.lists requested changes to this revision.Nov 29 2016, 6:05 AM
mclow.lists edited edge metadata.
mclow.lists added inline comments.
libcxx/include/algorithm
1499 ↗(On Diff #79463)

I just realized that we can't do this.
This imposes a requirement that the value_type be copy-constructible.

With this in place, we can't search a sequence of move-only types.

This revision now requires changes to proceed.Nov 29 2016, 6:05 AM
hiraditya added inline comments.Nov 29 2016, 6:38 AM
libcxx/include/algorithm
1499 ↗(On Diff #79463)

Ok, I'll remove this change while pushing. I'll change the subject as well, because now this patch is just removing the unused code.
Thanks for the review.

hiraditya marked an inline comment as done.Nov 29 2016, 6:38 AM
hiraditya updated this revision to Diff 79565.Nov 29 2016, 6:53 AM
hiraditya retitled this revision from Hoist redundant load to Remove unused code.
hiraditya edited edge metadata.
This revision was automatically updated to reflect the committed changes.
hiraditya added inline comments.Nov 29 2016, 9:36 AM
libcxx/include/algorithm
1499 ↗(On Diff #79463)

Are we allowed to call __search on a type which is not copy-constructible?