[PATCH] D48721: Patch to fix pragma metadata for do-while loops

Deepak Panickal via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 28 14:18:05 PDT 2018


deepak2427 updated this revision to Diff 153392.
deepak2427 added a comment.
Herald added a subscriber: zzheng.

Add tests.


https://reviews.llvm.org/D48721

Files:
  test/CodeGen/pragma-do-while-unroll.cpp
  test/CodeGen/pragma-do-while.cpp


Index: test/CodeGen/pragma-do-while.cpp
===================================================================
--- /dev/null
+++ test/CodeGen/pragma-do-while.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -O3 -fno-unroll-loops -S -emit-llvm %s -o - | FileCheck %s
+int test(int a[], int n) {
+  int i = 0;
+  int sum = 0;
+
+//CHECK-NOT: llvm.loop
+
+#pragma unroll 4
+  do
+  //CHECK: do.body:
+  //CHECK: llvm.loop
+  {
+    a[i] = a[i] + 1;
+    sum = sum + a[i];
+    i++;
+  } while (i < n);
+
+  i = 0;
+
+#pragma unroll 8
+  do
+  //CHECK: do.body{{[0-9]+}}:
+  //CHECK: llvm.loop
+  {
+    a[i] = a[i] + 1;
+    sum = sum + a[i];
+    i++;
+  } while (i < n);
+
+  return sum;
+}
Index: test/CodeGen/pragma-do-while-unroll.cpp
===================================================================
--- /dev/null
+++ test/CodeGen/pragma-do-while-unroll.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -O3 -funroll-loops -S -emit-llvm %s -o - | FileCheck %s
+int test(int a[], int n) {
+  int i = 0;
+  int sum = 0;
+
+#pragma unroll 3
+  do
+  //CHECK: do.body:
+  //CHECK: store i32 %add
+  //CHECK: store i32 %add.1
+  //CHECK: store i32 %add.2
+  //CHECK-NOT: store i32 %add.3
+  {
+    a[i] = a[i] + 1;
+    sum = sum + a[i];
+    i++;
+  } while (i < n);
+
+  i = 0;
+
+#pragma unroll 5
+  do
+  //CHECK: do.body{{[0-9]+}}:
+  //CHECK: store i32 %add{{[0-9]+}}
+  //CHECK: store i32 %add{{[0-9]+}}.1
+  //CHECK: store i32 %add{{[0-9]+}}.2
+  //CHECK: store i32 %add{{[0-9]+}}.3
+  //CHECK: store i32 %add{{[0-9]+}}.4
+  //CHECK-NOT: store i32 %add{{[0-9]+}}.5
+  {
+    a[i] = a[i] + 1;
+    sum = sum + a[i];
+    i++;
+  } while (i < n);
+
+  return sum;
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48721.153392.patch
Type: text/x-patch
Size: 1653 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180628/e4482a4c/attachment-0001.bin>


More information about the cfe-commits mailing list