xref: /aosp_15_r20/external/llvm/test/CodeGen/SystemZ/strcmp-nobuiltin.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; Test that strcmp won't be converted to CLST if calls are
2*9880d681SAndroid Build Coastguard Worker; marked with nobuiltin, eg. for sanitizers.
3*9880d681SAndroid Build Coastguard Worker;
4*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Workerdeclare signext i32 @strcmp(i8 *%src1, i8 *%src2)
7*9880d681SAndroid Build Coastguard Worker
8*9880d681SAndroid Build Coastguard Worker; Check a case where the result is used as an integer.
9*9880d681SAndroid Build Coastguard Workerdefine i32 @f1(i8 *%src1, i8 *%src2) {
10*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f1:
11*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: clst
12*9880d681SAndroid Build Coastguard Worker; CHECK: brasl %r14, strcmp
13*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
14*9880d681SAndroid Build Coastguard Worker  %res = call i32 @strcmp(i8 *%src1, i8 *%src2) nobuiltin
15*9880d681SAndroid Build Coastguard Worker  ret i32 %res
16*9880d681SAndroid Build Coastguard Worker}
17*9880d681SAndroid Build Coastguard Worker
18*9880d681SAndroid Build Coastguard Worker; Check a case where the result is tested for equality.
19*9880d681SAndroid Build Coastguard Workerdefine void @f2(i8 *%src1, i8 *%src2, i32 *%dest) {
20*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f2:
21*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: clst
22*9880d681SAndroid Build Coastguard Worker; CHECK: brasl %r14, strcmp
23*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
24*9880d681SAndroid Build Coastguard Worker  %res = call i32 @strcmp(i8 *%src1, i8 *%src2) nobuiltin
25*9880d681SAndroid Build Coastguard Worker  %cmp = icmp eq i32 %res, 0
26*9880d681SAndroid Build Coastguard Worker  br i1 %cmp, label %exit, label %store
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Workerstore:
29*9880d681SAndroid Build Coastguard Worker  store i32 0, i32 *%dest
30*9880d681SAndroid Build Coastguard Worker  br label %exit
31*9880d681SAndroid Build Coastguard Worker
32*9880d681SAndroid Build Coastguard Workerexit:
33*9880d681SAndroid Build Coastguard Worker  ret void
34*9880d681SAndroid Build Coastguard Worker}
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard Worker; Test a case where the result is used both as an integer and for
37*9880d681SAndroid Build Coastguard Worker; branching.
38*9880d681SAndroid Build Coastguard Workerdefine i32 @f3(i8 *%src1, i8 *%src2, i32 *%dest) {
39*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f3:
40*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: clst
41*9880d681SAndroid Build Coastguard Worker; CHECK: brasl %r14, strcmp
42*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
43*9880d681SAndroid Build Coastguard Workerentry:
44*9880d681SAndroid Build Coastguard Worker  %res = call i32 @strcmp(i8 *%src1, i8 *%src2) nobuiltin
45*9880d681SAndroid Build Coastguard Worker  %cmp = icmp slt i32 %res, 0
46*9880d681SAndroid Build Coastguard Worker  br i1 %cmp, label %exit, label %store
47*9880d681SAndroid Build Coastguard Worker
48*9880d681SAndroid Build Coastguard Workerstore:
49*9880d681SAndroid Build Coastguard Worker  store i32 0, i32 *%dest
50*9880d681SAndroid Build Coastguard Worker  br label %exit
51*9880d681SAndroid Build Coastguard Worker
52*9880d681SAndroid Build Coastguard Workerexit:
53*9880d681SAndroid Build Coastguard Worker  ret i32 %res
54*9880d681SAndroid Build Coastguard Worker}
55