[llvm] e770249 - update_test_checks: add new test
Nicolai Hähnle via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 16 13:07:16 PDT 2024
Author: Nicolai Hähnle
Date: 2024-04-16T22:04:33+02:00
New Revision: e770249d955e06f205e91017cd394d8670996168
URL: https://github.com/llvm/llvm-project/commit/e770249d955e06f205e91017cd394d8670996168
DIFF: https://github.com/llvm/llvm-project/commit/e770249d955e06f205e91017cd394d8670996168.diff
LOG: update_test_checks: add new test
This test is meant to demonstrate an upcoming change that replaces basic
block labels by FileCheck patterns.
Added:
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/phi-labels.ll
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/phi-labels.ll.expected
llvm/test/tools/UpdateTestChecks/update_test_checks/phi-labels.test
Modified:
Removed:
################################################################################
diff --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/phi-labels.ll b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/phi-labels.ll
new file mode 100644
index 00000000000000..4eb05b943f5067
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/phi-labels.ll
@@ -0,0 +1,39 @@
+; RUN: opt < %s -S | FileCheck %s
+
+define i32 @phi_after_label(i1 %cc) {
+entry:
+ br i1 %cc, label %then, label %end
+
+then:
+ br label %end
+
+end:
+ %r = phi i32 [ 0, %entry ], [ 1, %then ]
+ ret i32 %r
+}
+
+define void @phi_before_label(i32 %bound) {
+entry:
+ br label %loop
+
+loop:
+ %ctr = phi i32 [ 0, %entry ], [ %ctr.next, %loop ]
+ %ctr.next = add i32 %ctr, 1
+ %cc = icmp ult i32 %ctr.next, %bound
+ br i1 %cc, label %loop, label %end
+
+end:
+ ret void
+}
+
+define i32 @phi_after_label_unnamed(i1 %cc) {
+0:
+ br i1 %cc, label %1, label %2
+
+1:
+ br label %2
+
+2:
+ %r = phi i32 [ 0, %0 ], [ 1, %1 ]
+ ret i32 %r
+}
diff --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/phi-labels.ll.expected b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/phi-labels.ll.expected
new file mode 100644
index 00000000000000..1d21ebe547f689
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/phi-labels.ll.expected
@@ -0,0 +1,71 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
+; RUN: opt < %s -S | FileCheck %s
+
+define i32 @phi_after_label(i1 %cc) {
+; CHECK-LABEL: define i32 @phi_after_label(
+; CHECK-SAME: i1 [[CC:%.*]]) {
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br i1 [[CC]], label [[THEN:%.*]], label [[END:%.*]]
+; CHECK: then:
+; CHECK-NEXT: br label [[END]]
+; CHECK: end:
+; CHECK-NEXT: [[R:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ 1, [[THEN]] ]
+; CHECK-NEXT: ret i32 [[R]]
+;
+entry:
+ br i1 %cc, label %then, label %end
+
+then:
+ br label %end
+
+end:
+ %r = phi i32 [ 0, %entry ], [ 1, %then ]
+ ret i32 %r
+}
+
+define void @phi_before_label(i32 %bound) {
+; CHECK-LABEL: define void @phi_before_label(
+; CHECK-SAME: i32 [[BOUND:%.*]]) {
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: [[CTR:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[CTR_NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT: [[CTR_NEXT]] = add i32 [[CTR]], 1
+; CHECK-NEXT: [[CC:%.*]] = icmp ult i32 [[CTR_NEXT]], [[BOUND]]
+; CHECK-NEXT: br i1 [[CC]], label [[LOOP]], label [[END:%.*]]
+; CHECK: end:
+; CHECK-NEXT: ret void
+;
+entry:
+ br label %loop
+
+loop:
+ %ctr = phi i32 [ 0, %entry ], [ %ctr.next, %loop ]
+ %ctr.next = add i32 %ctr, 1
+ %cc = icmp ult i32 %ctr.next, %bound
+ br i1 %cc, label %loop, label %end
+
+end:
+ ret void
+}
+
+define i32 @phi_after_label_unnamed(i1 %cc) {
+; CHECK-LABEL: define i32 @phi_after_label_unnamed(
+; CHECK-SAME: i1 [[CC:%.*]]) {
+; CHECK-NEXT: br i1 [[CC]], label [[TMP1:%.*]], label [[TMP2:%.*]]
+; CHECK: 1:
+; CHECK-NEXT: br label [[TMP2]]
+; CHECK: 2:
+; CHECK-NEXT: [[R:%.*]] = phi i32 [ 0, [[TMP0:%.*]] ], [ 1, [[TMP1]] ]
+; CHECK-NEXT: ret i32 [[R]]
+;
+0:
+ br i1 %cc, label %1, label %2
+
+1:
+ br label %2
+
+2:
+ %r = phi i32 [ 0, %0 ], [ 1, %1 ]
+ ret i32 %r
+}
diff --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/phi-labels.test b/llvm/test/tools/UpdateTestChecks/update_test_checks/phi-labels.test
new file mode 100644
index 00000000000000..411c84de1dcba5
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/phi-labels.test
@@ -0,0 +1,5 @@
+# RUN: cp -f %S/Inputs/phi-labels.ll %t.ll && %update_test_checks --version 4 %t.ll
+# RUN:
diff -u %t.ll %S/Inputs/phi-labels.ll.expected
+## Check that running the script again does not change the result:
+# RUN: %update_test_checks %t.ll
+# RUN:
diff -u %t.ll %S/Inputs/phi-labels.ll.expected
More information about the llvm-commits
mailing list