[llvm] df6c26f - update_analyze_test_checks.py: fix --filter handling

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 7 04:41:22 PST 2022


Author: Roman Lebedev
Date: 2022-03-07T15:41:13+03:00
New Revision: df6c26fd3499d0770eff3922b90f576d7bde3880

URL: https://github.com/llvm/llvm-project/commit/df6c26fd3499d0770eff3922b90f576d7bde3880
DIFF: https://github.com/llvm/llvm-project/commit/df6c26fd3499d0770eff3922b90f576d7bde3880.diff

LOG: update_analyze_test_checks.py: fix --filter handling

In particular, after filtering the check lines can't necessarily
use `-NEXT`, they may not be one directly after another.

Added: 
    llvm/test/tools/UpdateTestChecks/update_analyze_test_checks/Inputs/x86-filter.ll
    llvm/test/tools/UpdateTestChecks/update_analyze_test_checks/Inputs/x86-filter.ll.filter.expected
    llvm/test/tools/UpdateTestChecks/update_analyze_test_checks/filter.test

Modified: 
    llvm/utils/UpdateTestChecks/common.py
    llvm/utils/update_analyze_test_checks.py

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/UpdateTestChecks/update_analyze_test_checks/Inputs/x86-filter.ll b/llvm/test/tools/UpdateTestChecks/update_analyze_test_checks/Inputs/x86-filter.ll
new file mode 100644
index 0000000000000..24c5be28692d7
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_analyze_test_checks/Inputs/x86-filter.ll
@@ -0,0 +1,10 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
+; RUN: opt < %s -passes='print<cost-model>' -mtriple=x86_64-pc-linux-gnu 2>&1 -disable-output -mattr=+sse2 | FileCheck %s --check-prefixes=SSE2
+
+define void @replication_i64_stride2() nounwind {
+  %vf2 = shufflevector <2 x i64> undef, <2 x i64> poison, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
+  %vf4 = shufflevector <4 x i64> undef, <4 x i64> poison, <8 x i32> <i32 0, i32 0, i32 1, i32 1, i32 2, i32 2, i32 3, i32 3>
+  %vf8 = shufflevector <8 x i64> undef, <8 x i64> poison, <16 x i32> <i32 0, i32 0, i32 1, i32 1, i32 2, i32 2, i32 3, i32 3, i32 4, i32 4, i32 5, i32 5, i32 6, i32 6, i32 7, i32 7>
+  %vf16 = shufflevector <16 x i64> undef, <16 x i64> poison, <32 x i32> <i32 0, i32 0, i32 1, i32 1, i32 2, i32 2, i32 3, i32 3, i32 4, i32 4, i32 5, i32 5, i32 6, i32 6, i32 7, i32 7, i32 8, i32 8, i32 9, i32 9, i32 10, i32 10, i32 11, i32 11, i32 12, i32 12, i32 13, i32 13, i32 14, i32 14, i32 15, i32 15>
+  ret void
+}

diff  --git a/llvm/test/tools/UpdateTestChecks/update_analyze_test_checks/Inputs/x86-filter.ll.filter.expected b/llvm/test/tools/UpdateTestChecks/update_analyze_test_checks/Inputs/x86-filter.ll.filter.expected
new file mode 100644
index 0000000000000..fd0d0a47bd870
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_analyze_test_checks/Inputs/x86-filter.ll.filter.expected
@@ -0,0 +1,14 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
+; RUN: opt < %s -passes='print<cost-model>' -mtriple=x86_64-pc-linux-gnu 2>&1 -disable-output -mattr=+sse2 | FileCheck %s --check-prefixes=SSE2
+
+define void @replication_i64_stride2() nounwind {
+; SSE2-LABEL: 'replication_i64_stride2'
+; SSE2:  Cost Model: Found an estimated cost of 18 for instruction: %vf4 = shufflevector <4 x i64> undef, <4 x i64> poison, <8 x i32> <i32 0, i32 0, i32 1, i32 1, i32 2, i32 2, i32 3, i32 3>
+; SSE2:  Cost Model: Found an estimated cost of 72 for instruction: %vf16 = shufflevector <16 x i64> undef, <16 x i64> poison, <32 x i32> <i32 0, i32 0, i32 1, i32 1, i32 2, i32 2, i32 3, i32 3, i32 4, i32 4, i32 5, i32 5, i32 6, i32 6, i32 7, i32 7, i32 8, i32 8, i32 9, i32 9, i32 10, i32 10, i32 11, i32 11, i32 12, i32 12, i32 13, i32 13, i32 14, i32 14, i32 15, i32 15>
+;
+  %vf2 = shufflevector <2 x i64> undef, <2 x i64> poison, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
+  %vf4 = shufflevector <4 x i64> undef, <4 x i64> poison, <8 x i32> <i32 0, i32 0, i32 1, i32 1, i32 2, i32 2, i32 3, i32 3>
+  %vf8 = shufflevector <8 x i64> undef, <8 x i64> poison, <16 x i32> <i32 0, i32 0, i32 1, i32 1, i32 2, i32 2, i32 3, i32 3, i32 4, i32 4, i32 5, i32 5, i32 6, i32 6, i32 7, i32 7>
+  %vf16 = shufflevector <16 x i64> undef, <16 x i64> poison, <32 x i32> <i32 0, i32 0, i32 1, i32 1, i32 2, i32 2, i32 3, i32 3, i32 4, i32 4, i32 5, i32 5, i32 6, i32 6, i32 7, i32 7, i32 8, i32 8, i32 9, i32 9, i32 10, i32 10, i32 11, i32 11, i32 12, i32 12, i32 13, i32 13, i32 14, i32 14, i32 15, i32 15>
+  ret void
+}

diff  --git a/llvm/test/tools/UpdateTestChecks/update_analyze_test_checks/filter.test b/llvm/test/tools/UpdateTestChecks/update_analyze_test_checks/filter.test
new file mode 100644
index 0000000000000..0be97d5d9e75d
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_analyze_test_checks/filter.test
@@ -0,0 +1,9 @@
+# REQUIRES: x86-registered-target
+
+## Check that --filter works properly.
+# RUN: cp -f %S/Inputs/x86-filter.ll %t.ll && %update_analyze_test_checks --filter="(vf4|vf16)" %t.ll
+# RUN: 
diff  -u %t.ll %S/Inputs/x86-filter.ll.filter.expected
+
+## Check that running the script again does not change the result:
+# RUN: %update_analyze_test_checks --filter="(vf4|vf16)" %t.ll
+# RUN: 
diff  -u %t.ll %S/Inputs/x86-filter.ll.filter.expected

diff  --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index c073f25d384be..38a0fd12625f4 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -916,12 +916,12 @@ def add_ir_checks(output_lines, comment_marker, prefix_list, func_dict,
              check_label_format, False, preserve_names, global_vars_seen_dict,
              is_filtered)
 
-def add_analyze_checks(output_lines, comment_marker, prefix_list, func_dict, func_name):
+def add_analyze_checks(output_lines, comment_marker, prefix_list, func_dict, func_name, is_filtered):
   check_label_format = '{} %s-LABEL: \'%s%s\''.format(comment_marker)
   global_vars_seen_dict = {}
   add_checks(output_lines, comment_marker, prefix_list, func_dict, func_name,
              check_label_format, False, True, global_vars_seen_dict,
-             is_filtered = False)
+             is_filtered)
 
 def build_global_values_dictionary(glob_val_dict, raw_tool_output, prefixes):
   for nameless_value in nameless_values:

diff  --git a/llvm/utils/update_analyze_test_checks.py b/llvm/utils/update_analyze_test_checks.py
index cfb063294364d..15708e52c133c 100755
--- a/llvm/utils/update_analyze_test_checks.py
+++ b/llvm/utils/update_analyze_test_checks.py
@@ -149,7 +149,8 @@ def main():
             continue
 
         # Print out the various check lines here.
-        common.add_analyze_checks(output_lines, ';', prefix_list, func_dict, func_name)
+        common.add_analyze_checks(output_lines, ';', prefix_list, func_dict, func_name,
+                                  is_filtered=builder.is_filtered())
         is_in_function_start = False
 
       if is_in_function:


        


More information about the llvm-commits mailing list