[PATCH] D19870: Adding test cases showing the behavior of LoopUnrollPass according to optnone and optsize attributes

Marianne Mailhot-Sarrasin via llvm-commits llvm-commits at lists.llvm.org
Tue May 3 07:42:19 PDT 2016


mamai created this revision.
mamai added a reviewer: mzolotukhin.
mamai added subscribers: mcrosier, llvm-commits.
mamai set the repository for this revision to rL LLVM.

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

Repository:
  rL LLVM

http://reviews.llvm.org/D19870

Files:
  test/Transforms/LoopUnroll/unroll-optnone.ll
  test/Transforms/LoopUnroll/unroll-optsize1.ll
  test/Transforms/LoopUnroll/unroll-optsize2.ll

Index: test/Transforms/LoopUnroll/unroll-optsize2.ll
===================================================================
--- test/Transforms/LoopUnroll/unroll-optsize2.ll
+++ test/Transforms/LoopUnroll/unroll-optsize2.ll
@@ -0,0 +1,21 @@
+; RUN: opt < %s -S -loop-unroll | FileCheck %s
+
+; This test shows that with optsize attribute, the loop is not unrolled.
+
+define void @unroll_optsize() nounwind optsize {
+entry:
+  br label %loop
+
+loop:
+  %iv = phi i32 [ 0, %entry ], [ %inc, %loop ]
+  %inc = add i32 %iv, 1
+  %exitcnd = icmp uge i32 %inc, 1024
+  br i1 %exitcnd, label %exit, label %loop
+
+exit:
+  ret void
+}
+
+; CHECK:      phi
+; CHECK-NEXT: add
+; CHECK-NEXT: icmp
Index: test/Transforms/LoopUnroll/unroll-optsize1.ll
===================================================================
--- test/Transforms/LoopUnroll/unroll-optsize1.ll
+++ test/Transforms/LoopUnroll/unroll-optsize1.ll
@@ -0,0 +1,25 @@
+; RUN: opt < %s -S -loop-unroll -unroll-count=4 | FileCheck %s
+
+; This test shows that with optsize attribute, the loop is unrolled
+; according to the specified unroll factor.
+
+define void @unroll_optsize() nounwind optsize {
+entry:
+  br label %loop
+
+loop:
+  %iv = phi i32 [ 0, %entry ], [ %inc, %loop ]
+  %inc = add i32 %iv, 1
+  %exitcnd = icmp uge i32 %inc, 1024
+  br i1 %exitcnd, label %exit, label %loop
+
+exit:
+  ret void
+}
+
+; CHECK:      phi
+; CHECK-NEXT: add
+; CHECK-NEXT: add
+; CHECK-NEXT: add
+; CHECK-NEXT: add
+; CHECK-NEXT: icmp
Index: test/Transforms/LoopUnroll/unroll-optnone.ll
===================================================================
--- test/Transforms/LoopUnroll/unroll-optnone.ll
+++ test/Transforms/LoopUnroll/unroll-optnone.ll
@@ -0,0 +1,22 @@
+; RUN: opt < %s -S -loop-unroll -unroll-count=4 | FileCheck %s
+
+; This test shows that with optnone attribute, the loop is not unrolled
+; even if an unroll factor was specified.
+
+define void @unroll_optnone() nounwind optnone noinline {
+entry:
+  br label %loop
+
+loop:
+  %iv = phi i32 [ 0, %entry ], [ %inc, %loop ]
+  %inc = add i32 %iv, 1
+  %exitcnd = icmp uge i32 %inc, 1024
+  br i1 %exitcnd, label %exit, label %loop
+
+exit:
+  ret void
+}
+
+; CHECK:      phi
+; CHECK-NEXT: add
+; CHECK-NEXT: icmp


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19870.55993.patch
Type: text/x-patch
Size: 2309 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160503/bdb96e5b/attachment.bin>


More information about the llvm-commits mailing list