This is an archive of the discontinued LLVM Phabricator instance.

Adding test cases showing the behavior of LoopUnrollPass according to optnone and optsize attributes
ClosedPublic

Authored by mamai on May 3 2016, 7:42 AM.

Details

Summary

The unroll pass was disabled by clang in /Os. Those new test cases shows that the pass will behave correctly even if it is not fully disabled. This patch is related to http://reviews.llvm.org/D19827, which would re-enable the pass in /Os.

Diff Detail

Repository
rL LLVM

Event Timeline

mamai updated this revision to Diff 55993.May 3 2016, 7:42 AM
mamai retitled this revision from to Adding test cases showing the behavior of LoopUnrollPass according to optnone and optsize attributes.
mamai updated this object.
mamai added a reviewer: mzolotukhin.
mamai set the repository for this revision to rL LLVM.
mamai added subscribers: mcrosier, llvm-commits.

-Please refactor the optsize tests into a single file (e.g., unroll-optsize.ll). If you factored all the test into a single file that would be even better. We want to minimize the number of times opt is invoked.
-Please add a test case for minsize. In this case we don't want to unroll the loop, if I'm not mistaken.

How are we handling -O1? The clang patch D19827 will have a functional change at this optimization level, if I'm not mistaken.

test/Transforms/LoopUnroll/unroll-optnone.ll
19 ↗(On Diff #55993)

Please add a CHECK-LABEL directive. I.e.,

CHECK-LABEL: @unroll_optnone
test/Transforms/LoopUnroll/unroll-optsize1.ll
19 ↗(On Diff #55993)

Please add a CHECK-LABEL directive.

test/Transforms/LoopUnroll/unroll-optsize2.ll
18 ↗(On Diff #55993)

Please add a CHECK-LABEL directive.

mamai added a comment.May 3 2016, 11:16 AM
  • I am not sure it is possible to merge the optsize tests in one call to opt, since one of them use the -unroll-count parameter and not the other. Do you see another way to do that?
  • I am not sure it is possible to merge the optsize tests in one call to opt, since one of them use the -unroll-count parameter and not the other. Do you see another way to do that?

You can have multiple RUN lines in a file. To differentiate the runs you can use the FileCheck --check-prefix command.

For example, look at the top of the loop-remarks.ll test in llvm/test/Transforms/LoopUnroll.

Something like:

; RUN: opt < %s -S -loop-unroll  | FileCheck %s
; RUN: opt < %s -S -loop-unroll -unroll-count=4 | FileCheck -check-prefix=UNROLLCOUNT4 %s

By default, FileCheck assumes the prefix is CHECK. Therefore, unroll-optnone.ll and unroll-optsize2.ll can just use the CHECK: directive, while all the CHECK directives in the unroll-optsize1.ll file will be UNROLLCOUNT4:

Hopefully, that all makes sense.

In that case, please add a test case with minsize that shows the expected behavior.

I'm still interested to know how loop unroll behaves at -O1.

mamai added a comment.May 3 2016, 1:02 PM

Ok, thanks! I will modify the test cases and merge them in one file.

For /O1, I think you are right about the clang patch having a functional change. I don't see anything preventing the unrolling to execute in /O1.

mamai updated this revision to Diff 56058.May 3 2016, 1:30 PM
  • Merged test cases into one file.
  • Added a case for minsize.
  • Modified the test that shows the behavior of optsize when no unroll factor is specified.
mamai updated this object.May 4 2016, 6:15 AM
mcrosier accepted this revision.May 4 2016, 8:37 AM
mcrosier added a reviewer: mcrosier.

lgtm. thanks.

This revision is now accepted and ready to land.May 4 2016, 8:37 AM
This revision was automatically updated to reflect the committed changes.