Home | History | Annotate | Download | only in SystemZ
      1 ; Test strcmp using CLST, i32 version.
      2 ;
      3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
      4 
      5 declare signext i32 @strcmp(i8 *%src1, i8 *%src2)
      6 
      7 ; Check a case where the result is used as an integer.
      8 define i32 @f1(i8 *%src1, i8 *%src2) {
      9 ; CHECK-LABEL: f1:
     10 ; CHECK: lhi %r0, 0
     11 ; CHECK: [[LABEL:\.[^:]*]]:
     12 ; CHECK: clst %r2, %r3
     13 ; CHECK-NEXT: jo [[LABEL]]
     14 ; CHECK-NEXT: BB#{{[0-9]+}}
     15 ; CHECK-NEXT: ipm [[REG:%r[0-5]]]
     16 ; CHECK: srl [[REG]], 28
     17 ; CHECK: rll %r2, [[REG]], 31
     18 ; CHECK: br %r14
     19   %res = call i32 @strcmp(i8 *%src1, i8 *%src2)
     20   ret i32 %res
     21 }
     22 
     23 ; Check a case where the result is tested for equality.
     24 define void @f2(i8 *%src1, i8 *%src2, i32 *%dest) {
     25 ; CHECK-LABEL: f2:
     26 ; CHECK: lhi %r0, 0
     27 ; CHECK: [[LABEL:\.[^:]*]]:
     28 ; CHECK: clst %r2, %r3
     29 ; CHECK-NEXT: jo [[LABEL]]
     30 ; CHECK-NEXT: BB#{{[0-9]+}}
     31 ; CHECK-NEXT: je {{\.L.*}}
     32 ; CHECK: br %r14
     33   %res = call i32 @strcmp(i8 *%src1, i8 *%src2)
     34   %cmp = icmp eq i32 %res, 0
     35   br i1 %cmp, label %exit, label %store
     36 
     37 store:
     38   store i32 0, i32 *%dest
     39   br label %exit
     40 
     41 exit:
     42   ret void
     43 }
     44 
     45 ; Test a case where the result is used both as an integer and for
     46 ; branching.
     47 define i32 @f3(i8 *%src1, i8 *%src2, i32 *%dest) {
     48 ; CHECK-LABEL: f3:
     49 ; CHECK: lhi %r0, 0
     50 ; CHECK: [[LABEL:\.[^:]*]]:
     51 ; CHECK: clst %r2, %r3
     52 ; CHECK-NEXT: jo [[LABEL]]
     53 ; CHECK-NEXT: BB#{{[0-9]+}}
     54 ; CHECK-NEXT: ipm [[REG:%r[0-5]]]
     55 ; CHECK: srl [[REG]], 28
     56 ; CHECK: rll %r2, [[REG]], 31
     57 ; CHECK: jl {{\.L*}}
     58 ; CHECK: br %r14
     59 entry:
     60   %res = call i32 @strcmp(i8 *%src1, i8 *%src2)
     61   %cmp = icmp slt i32 %res, 0
     62   br i1 %cmp, label %exit, label %store
     63 
     64 store:
     65   store i32 0, i32 *%dest
     66   br label %exit
     67 
     68 exit:
     69   ret i32 %res
     70 }
     71