This is an archive of the discontinued LLVM Phabricator instance.

[LIR] Add support for creating memsets from loops with a negative stride.
ClosedPublic

Authored by mcrosier on Oct 27 2015, 11:18 AM.

Details

Summary

This change adds support for transforming loops such as

void test (unsigned *f) {

for (int i = 65536; i >= 0; i--) {
   f[i] = 0;
}

}

into memsets. Previously, we were unable to transform loops with negative strides.

Passes all correctness for Spec2000, Spec2006, and LNT. Transforms a number of benchmarks in Spec2000 and Spec2006.

Please take a look.

Chad

Diff Detail

Repository
rL LLVM

Event Timeline

mcrosier updated this revision to Diff 38573.Oct 27 2015, 11:18 AM
mcrosier retitled this revision from to [LIR] Add support for creating memsets from loops with a negative stride..
mcrosier updated this object.
mcrosier set the repository for this revision to rL LLVM.
mcrosier added a subscriber: llvm-commits.
mssimpso edited edge metadata.Oct 27 2015, 1:51 PM

This looks reasonable to me, but I'll let someone else approve.

lib/Transforms/Scalar/LoopIdiomRecognize.cpp
33

You can update this comment to reflect that we can handle negative strides with this patch. Loop reversal is a separate optimization, so I think it makes sense to catch the simple case here, especially since the implementation is minimal. The follow-on patch would be to handle the negative stride in processLoopMemSet.

mcrosier updated this revision to Diff 38596.Oct 27 2015, 2:28 PM
mcrosier edited edge metadata.
mcrosier removed rL LLVM as the repository for this revision.

Remove comment about adding support for negative strides.

mcrosier marked an inline comment as done.Oct 27 2015, 2:29 PM

Thanks for the feedback, Matt.

lib/Transforms/Scalar/LoopIdiomRecognize.cpp
33–38

I do plan on implementing the follow-on patch, but I wanted to land this simple patch first.

chandlerc accepted this revision.Oct 27 2015, 2:33 PM
chandlerc edited edge metadata.

LGTM, awesome patch!

This revision is now accepted and ready to land.Oct 27 2015, 2:33 PM
mcrosier marked an inline comment as done.Oct 28 2015, 11:24 AM

Committed in r251518. Thanks, Chandler.

mcrosier closed this revision.Oct 28 2015, 11:24 AM