r374838 - In the new pass manager use PTO.LoopUnrolling to determine when and how

Eric Christopher via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 14 15:56:07 PDT 2019


Author: echristo
Date: Mon Oct 14 15:56:07 2019
New Revision: 374838

URL: http://llvm.org/viewvc/llvm-project?rev=374838&view=rev
Log:
In the new pass manager use PTO.LoopUnrolling to determine when and how
we will unroll loops. Also comment a few occasions where we need to
know whether or not we're forcing the unwinder or not.

The default before and after this patch is for LoopUnroll to be enabled,
and for it to use a cost model to determine whether to unroll the loop
(`OnlyWhenForced = false`). Before this patch, disabling loop unroll
would not run the LoopUnroll pass. After this patch, the LoopUnroll pass
is being run, but it restricts unrolling to only the loops marked by a
pragma (`OnlyWhenForced = true`).

In addition, this patch disables the UnrollAndJam pass when disabling unrolling.

Testcase is in clang because it's controlling how the loop optimizer
is being set up and there's no other way to trigger the behavior.

Added:
    cfe/trunk/test/Misc/loop-opt-setup.c

Added: cfe/trunk/test/Misc/loop-opt-setup.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/loop-opt-setup.c?rev=374838&view=auto
==============================================================================
--- cfe/trunk/test/Misc/loop-opt-setup.c (added)
+++ cfe/trunk/test/Misc/loop-opt-setup.c Mon Oct 14 15:56:07 2019
@@ -0,0 +1,12 @@
+// RUN: %clang -O1 -fexperimental-new-pass-manager -fno-unroll-loops -S -o - %s -emit-llvm | FileCheck %s
+// RUN: %clang -O1 -fno-unroll-loops -S -o - %s -emit-llvm | FileCheck %s
+extern int a[16];
+int b = 0;
+int foo(void) {
+#pragma unroll
+  for (int i = 0; i < 16; ++i)
+    a[i] = b += 2;
+  return b;
+}
+// CHECK-NOT: br i1
+




More information about the cfe-commits mailing list