Home | History | Annotate | Download | only in SystemZ
      1 ; Test proper extension of 8-bit/16-bit cmpxchg.
      2 ;
      3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
      4 
      5 ; CHECK-LABEL: f1
      6 ; CHECK: crjlh
      7 ; CHECK-NOT: llcr
      8 ; CHECK-NOT: cr
      9 ; CHECK: llgcr %r2, [[RES:%r[0-9]+]]
     10 ; CHECK-NOT: llcr
     11 ; CHECK-NOT: cr
     12 define zeroext i8 @f1(i8* nocapture, i8 zeroext, i8 zeroext) {
     13   %cx = cmpxchg i8* %0, i8 %1, i8 %2 seq_cst seq_cst
     14   %res = extractvalue { i8, i1 } %cx, 0
     15   ret i8 %res
     16 }
     17 
     18 ; CHECK-LABEL: f2
     19 ; CHECK: crjlh
     20 ; CHECK-NOT: llhr
     21 ; CHECK-NOT: cr
     22 ; CHECK: llghr %r2, [[RES:%r[0-9]+]]
     23 ; CHECK-NOT: llhr
     24 ; CHECK-NOT: cr
     25 define zeroext i16 @f2(i16* nocapture, i16 zeroext, i16 zeroext) {
     26   %cx = cmpxchg i16* %0, i16 %1, i16 %2 seq_cst seq_cst
     27   %res = extractvalue { i16, i1 } %cx, 0
     28   ret i16 %res
     29 }
     30 
     31 ; CHECK-LABEL: f3
     32 ; CHECK: crjlh
     33 ; CHECK-NOT: llcr
     34 ; CHECK-NOT: cr
     35 ; CHECK: lgbr %r2, [[RES:%r[0-9]+]]
     36 ; CHECK-NOT: llcr
     37 ; CHECK-NOT: cr
     38 define signext i8 @f3(i8* nocapture, i8 signext, i8 signext) {
     39   %cx = cmpxchg i8* %0, i8 %1, i8 %2 seq_cst seq_cst
     40   %res = extractvalue { i8, i1 } %cx, 0
     41   ret i8 %res
     42 }
     43 
     44 ; CHECK-LABEL: f4
     45 ; CHECK: crjlh
     46 ; CHECK-NOT: llhr
     47 ; CHECK-NOT: cr
     48 ; CHECK: lghr %r2, [[RES:%r[0-9]+]]
     49 ; CHECK-NOT: llhr
     50 ; CHECK-NOT: cr
     51 define signext i16 @f4(i16* nocapture, i16 signext, i16 signext) {
     52   %cx = cmpxchg i16* %0, i16 %1, i16 %2 seq_cst seq_cst
     53   %res = extractvalue { i16, i1 } %cx, 0
     54   ret i16 %res
     55 }
     56 
     57 ; Now use the comparison result.
     58 ; CHECK-LABEL: f5
     59 ; CHECK: llcr [[REG:%r[0-9]+]], [[RES:%r[0-9]+]]
     60 ; CHECK: cr [[REG]], %r3
     61 define zeroext i8 @f5(i8* nocapture, i8 zeroext, i8 zeroext) {
     62   %cx = cmpxchg i8* %0, i8 %1, i8 %2 seq_cst seq_cst
     63   %res = extractvalue { i8, i1 } %cx, 1
     64   %xres = sext i1 %res to i8
     65   ret i8 %xres
     66 }
     67 
     68 ; Now use the comparison result and zero-extended old value.
     69 ; CHECK-LABEL: f6
     70 ; CHECK: llcr [[REG:%r[0-9]+]], [[RES:%r[0-9]+]]
     71 ; CHECK: st [[REG]], 0(%r5)
     72 ; CHECK: cr [[REG]], %r3
     73 define zeroext i8 @f6(i8* nocapture, i8 zeroext, i8 zeroext, i32*) {
     74   %cx = cmpxchg i8* %0, i8 %1, i8 %2 seq_cst seq_cst
     75   %old = extractvalue { i8, i1 } %cx, 0
     76   %xold = zext i8 %old to i32
     77   store i32 %xold, i32* %3
     78   %res = extractvalue { i8, i1 } %cx, 1
     79   %xres = sext i1 %res to i8
     80   ret i8 %xres
     81 }
     82