Skip to content

Commit c35ea62

Browse files
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
1 parent c712ab8 commit c35ea62

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; Example input for update_test_checks (taken from test/Transforms/SLPVectorizer/extractlements-gathered-first-node.ll)
2+
; RUN: %if x86-registered-target %{ opt -S --passes=slp-vectorizer -slp-threshold=-99999 -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s %}
3+
; RUN: %if aarch64-registered-target %{ opt -S --passes=slp-vectorizer -slp-threshold=-99999 -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s %}
4+
5+
define void @test() {
6+
bb:
7+
%0 = extractelement <4 x i32> zeroinitializer, i32 0
8+
%1 = extractelement <2 x i32> zeroinitializer, i32 0
9+
%icmp = icmp ult i32 %0, %1
10+
ret void
11+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2+
; Example input for update_test_checks (taken from test/Transforms/SLPVectorizer/extractlements-gathered-first-node.ll)
3+
; RUN: %if x86-registered-target %{ opt -S --passes=slp-vectorizer -slp-threshold=-99999 -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s %}
4+
; RUN: %if aarch64-registered-target %{ opt -S --passes=slp-vectorizer -slp-threshold=-99999 -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s %}
5+
6+
define void @test() {
7+
; CHECK-LABEL: define void @test() {
8+
; CHECK-NEXT: bb:
9+
; CHECK-NEXT: [[TMP0:%.*]] = extractelement <4 x i32> zeroinitializer, i32 0
10+
; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i32> zeroinitializer, i32 0
11+
; CHECK-NEXT: [[ICMP:%.*]] = icmp ult i32 [[TMP0]], [[TMP1]]
12+
; CHECK-NEXT: ret void
13+
;
14+
bb:
15+
%0 = extractelement <4 x i32> zeroinitializer, i32 0
16+
%1 = extractelement <2 x i32> zeroinitializer, i32 0
17+
%icmp = icmp ult i32 %0, %1
18+
ret void
19+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## Basic test checking that update_test_checks.py works correctly with %if in RUN line
2+
# RUN: cp -f %S/Inputs/if_target.ll %t.ll && %update_test_checks %t.ll --version 4
3+
# RUN: diff -u %t.ll %S/Inputs/if_target.ll.expected
4+
## Check that running the script again does not change the result:
5+
# RUN: %update_test_checks %t.ll
6+
# RUN: diff -u %t.ll %S/Inputs/if_target.ll.expected

llvm/utils/update_test_checks.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,13 @@ def main():
123123
common.warn("Skipping unparsable RUN line: " + l)
124124
continue
125125

126-
commands = [cmd.strip() for cmd in l.split("|")]
126+
cropped_content = l
127+
if "%if" in l:
128+
match = re.search(r"%{\s*(.*?)\s*%}", l)
129+
if match:
130+
cropped_content = match.group(1)
131+
132+
commands = [cmd.strip() for cmd in cropped_content.split("|")]
127133
assert len(commands) >= 2
128134
preprocess_cmd = None
129135
if len(commands) > 2:

0 commit comments

Comments
 (0)