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

Alina Sbirlea via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 24 10:39:03 PDT 2019


This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361653: [NewPassManager] Add tuning option: LoopUnrolling [clang-change] (authored by asbirlea, committed by ).
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D61620?vs=198704&id=201285#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61620

Files:
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/test/CodeGen/loop-unroll.c


Index: cfe/trunk/test/CodeGen/loop-unroll.c
===================================================================
--- cfe/trunk/test/CodeGen/loop-unroll.c
+++ cfe/trunk/test/CodeGen/loop-unroll.c
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -S -O1 -funroll-loops -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -S -O1 -fno-unroll-loops -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -fexperimental-new-pass-manager -S -O1 -funroll-loops -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -fexperimental-new-pass-manager -S -O1 -fno-unroll-loops -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+
+// CHECK-ENABLE-UNROLL-LABEL: @for_test()
+// CHECK-ENABLE-UNROLL: br label %[[FORBODY:[a-z0-9_\.]+]]
+// CHECK-ENABLE-UNROLL: [[FORBODY]]:
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: br i1 %[[EXITCOND:[a-z0-9_\.]+]], label %[[FORBODY5:[a-z0-9_\.]+]], label %[[FORBODY]]
+// CHECK-ENABLE-UNROLL: [[FORBODY5]]:
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+
+// CHECK-DISABLE-UNROLL-LABEL: @for_test()
+// CHECK-DISABLE-UNROLL: br label %[[FORBODY:[a-z0-9_\.]+]]
+// CHECK-DISABLE-UNROLL: [[FORBODY]]:
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL-NOT: store
+// CHECK-DISABLE-UNROLL: br i1 %[[EXITCOND:[a-z0-9_\.]+]], label %[[FORBODY5:[a-z0-9_\.]+]], label %[[FORBODY]]
+// CHECK-DISABLE-UNROLL: [[FORBODY5]]:
+// CHECK-DISABLE-UNROLL: fmul
+// CHECK-DISABLE-UNROLL: fadd
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL: fmul
+// CHECK-DISABLE-UNROLL: fadd
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL-NOT: fmul
+// CHECK-DISABLE-UNROLL-NOT: fadd
+// CHECK-DISABLE-UNROLL-NOT: store
+
+int printf(const char * restrict format, ...);
+
+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: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -1051,6 +1051,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.201285.patch
Type: text/x-patch
Size: 2910 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190524/0629023c/attachment.bin>


More information about the cfe-commits mailing list