[PATCH] D61620: [NewPassManager] Add tuning option: LoopUnrolling [clang-change]

Alina Sbirlea via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 7 16:12:58 PDT 2019


asbirlea updated this revision to Diff 198560.
asbirlea added a comment.
Herald added a subscriber: zzheng.

Added test. Last RUN line fails before this patch (i.e. unrolling is not disabled with the given flag in the new pass manager).


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61620/new/

https://reviews.llvm.org/D61620

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGenCXX/no-pragma-loop-unroll.cpp


Index: test/CodeGenCXX/no-pragma-loop-unroll.cpp
===================================================================
--- /dev/null
+++ test/CodeGenCXX/no-pragma-loop-unroll.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang -S -c -O1 -funroll-loops -std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang -S -c -O1 -fno-unroll-loops -std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+// RUN: %clang -fexperimental-new-pass-manager -S -c -O1 -funroll-loops -std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang -fexperimental-new-pass-manager -S -c -O1 -fno-unroll-loops -std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+
+// CHECK-ENABLE-UNROLL: for.body:
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: for.body5:
+
+// CHECK-DISABLE-UNROLL: for.body:
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL-NOT: store
+// CHECK-DISABLE-UNROLL: for.body5:
+
+#include <stdio.h>
+
+void for_test() {
+  double A[1000], B[1000];
+  int L = 500;
+  for (int i = 0; i < L; i++) {
+    A[i] = i;
+  }
+  for (int i = 0; i < L; i++) {
+    B[i] = A[i]*5;
+    B[i]++;
+    A[i] *= 7;
+    A[i]++;
+  }
+  printf("%lf %lf\n", A[0], B[0]);
+}
Index: lib/CodeGen/BackendUtil.cpp
===================================================================
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -1026,6 +1026,7 @@
   }
 
   PipelineTuningOptions PTO;
+  PTO.LoopUnrolling = CodeGenOpts.UnrollLoops;
   // For historical reasons, loop interleaving is set to mirror setting for loop
   // unrolling.
   PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61620.198560.patch
Type: text/x-patch
Size: 1727 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190507/068a1b53/attachment.bin>


More information about the cfe-commits mailing list