[llvm] c35ea62 - update_test_checks: recognize %if in RUN line (#108972)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 23 04:44:45 PDT 2024
Author: Elvina Yakubova
Date: 2024-09-23T12:44:42+01:00
New Revision: c35ea627df441a3650f986ca79954b4b9d16bf24
URL: https://github.com/llvm/llvm-project/commit/c35ea627df441a3650f986ca79954b4b9d16bf24
DIFF: https://github.com/llvm/llvm-project/commit/c35ea627df441a3650f986ca79954b4b9d16bf24.diff
LOG: update_test_checks: recognize %if in RUN line (#108972)
Recognize %if for target-specific cases in RUN line and keep only tool
command with options
Added:
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/if_target.ll
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/if_target.ll.expected
llvm/test/tools/UpdateTestChecks/update_test_checks/if_target.test
Modified:
llvm/utils/update_test_checks.py
Removed:
################################################################################
diff --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/if_target.ll b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/if_target.ll
new file mode 100644
index 00000000000000..63d9d5c90d4b44
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/if_target.ll
@@ -0,0 +1,11 @@
+; Example input for update_test_checks (taken from test/Transforms/SLPVectorizer/extractlements-gathered-first-node.ll)
+; RUN: %if x86-registered-target %{ opt -S --passes=slp-vectorizer -slp-threshold=-99999 -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s %}
+; RUN: %if aarch64-registered-target %{ opt -S --passes=slp-vectorizer -slp-threshold=-99999 -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s %}
+
+define void @test() {
+bb:
+ %0 = extractelement <4 x i32> zeroinitializer, i32 0
+ %1 = extractelement <2 x i32> zeroinitializer, i32 0
+ %icmp = icmp ult i32 %0, %1
+ ret void
+}
diff --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/if_target.ll.expected b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/if_target.ll.expected
new file mode 100644
index 00000000000000..a744acd53f9822
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/if_target.ll.expected
@@ -0,0 +1,19 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
+; Example input for update_test_checks (taken from test/Transforms/SLPVectorizer/extractlements-gathered-first-node.ll)
+; RUN: %if x86-registered-target %{ opt -S --passes=slp-vectorizer -slp-threshold=-99999 -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s %}
+; RUN: %if aarch64-registered-target %{ opt -S --passes=slp-vectorizer -slp-threshold=-99999 -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s %}
+
+define void @test() {
+; CHECK-LABEL: define void @test() {
+; CHECK-NEXT: bb:
+; CHECK-NEXT: [[TMP0:%.*]] = extractelement <4 x i32> zeroinitializer, i32 0
+; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i32> zeroinitializer, i32 0
+; CHECK-NEXT: [[ICMP:%.*]] = icmp ult i32 [[TMP0]], [[TMP1]]
+; CHECK-NEXT: ret void
+;
+bb:
+ %0 = extractelement <4 x i32> zeroinitializer, i32 0
+ %1 = extractelement <2 x i32> zeroinitializer, i32 0
+ %icmp = icmp ult i32 %0, %1
+ ret void
+}
diff --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/if_target.test b/llvm/test/tools/UpdateTestChecks/update_test_checks/if_target.test
new file mode 100644
index 00000000000000..3d8427b943c654
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/if_target.test
@@ -0,0 +1,6 @@
+## Basic test checking that update_test_checks.py works correctly with %if in RUN line
+# RUN: cp -f %S/Inputs/if_target.ll %t.ll && %update_test_checks %t.ll --version 4
+# RUN:
diff -u %t.ll %S/Inputs/if_target.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/if_target.ll.expected
\ No newline at end of file
diff --git a/llvm/utils/update_test_checks.py b/llvm/utils/update_test_checks.py
index 16f3e618770b20..b413c253e39757 100755
--- a/llvm/utils/update_test_checks.py
+++ b/llvm/utils/update_test_checks.py
@@ -123,7 +123,13 @@ def main():
common.warn("Skipping unparsable RUN line: " + l)
continue
- commands = [cmd.strip() for cmd in l.split("|")]
+ cropped_content = l
+ if "%if" in l:
+ match = re.search(r"%{\s*(.*?)\s*%}", l)
+ if match:
+ cropped_content = match.group(1)
+
+ commands = [cmd.strip() for cmd in cropped_content.split("|")]
assert len(commands) >= 2
preprocess_cmd = None
if len(commands) > 2:
More information about the llvm-commits
mailing list