Home | History | Annotate | Download | only in SystemZ
      1 ; Test 32-bit floating-point comparison.
      2 ;
      3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
      4 
      5 declare float @foo()
      6 
      7 ; Check comparison with registers.
      8 define i64 @f1(i64 %a, i64 %b, float %f1, float %f2) {
      9 ; CHECK-LABEL: f1:
     10 ; CHECK: cebr %f0, %f2
     11 ; CHECK-NEXT: je
     12 ; CHECK: lgr %r2, %r3
     13 ; CHECK: br %r14
     14   %cond = fcmp oeq float %f1, %f2
     15   %res = select i1 %cond, i64 %a, i64 %b
     16   ret i64 %res
     17 }
     18 
     19 ; Check the low end of the CEB range.
     20 define i64 @f2(i64 %a, i64 %b, float %f1, float *%ptr) {
     21 ; CHECK-LABEL: f2:
     22 ; CHECK: ceb %f0, 0(%r4)
     23 ; CHECK-NEXT: je
     24 ; CHECK: lgr %r2, %r3
     25 ; CHECK: br %r14
     26   %f2 = load float *%ptr
     27   %cond = fcmp oeq float %f1, %f2
     28   %res = select i1 %cond, i64 %a, i64 %b
     29   ret i64 %res
     30 }
     31 
     32 ; Check the high end of the aligned CEB range.
     33 define i64 @f3(i64 %a, i64 %b, float %f1, float *%base) {
     34 ; CHECK-LABEL: f3:
     35 ; CHECK: ceb %f0, 4092(%r4)
     36 ; CHECK-NEXT: je
     37 ; CHECK: lgr %r2, %r3
     38 ; CHECK: br %r14
     39   %ptr = getelementptr float *%base, i64 1023
     40   %f2 = load float *%ptr
     41   %cond = fcmp oeq float %f1, %f2
     42   %res = select i1 %cond, i64 %a, i64 %b
     43   ret i64 %res
     44 }
     45 
     46 ; Check the next word up, which needs separate address logic.
     47 ; Other sequences besides this one would be OK.
     48 define i64 @f4(i64 %a, i64 %b, float %f1, float *%base) {
     49 ; CHECK-LABEL: f4:
     50 ; CHECK: aghi %r4, 4096
     51 ; CHECK: ceb %f0, 0(%r4)
     52 ; CHECK-NEXT: je
     53 ; CHECK: lgr %r2, %r3
     54 ; CHECK: br %r14
     55   %ptr = getelementptr float *%base, i64 1024
     56   %f2 = load float *%ptr
     57   %cond = fcmp oeq float %f1, %f2
     58   %res = select i1 %cond, i64 %a, i64 %b
     59   ret i64 %res
     60 }
     61 
     62 ; Check negative displacements, which also need separate address logic.
     63 define i64 @f5(i64 %a, i64 %b, float %f1, float *%base) {
     64 ; CHECK-LABEL: f5:
     65 ; CHECK: aghi %r4, -4
     66 ; CHECK: ceb %f0, 0(%r4)
     67 ; CHECK-NEXT: je
     68 ; CHECK: lgr %r2, %r3
     69 ; CHECK: br %r14
     70   %ptr = getelementptr float *%base, i64 -1
     71   %f2 = load float *%ptr
     72   %cond = fcmp oeq float %f1, %f2
     73   %res = select i1 %cond, i64 %a, i64 %b
     74   ret i64 %res
     75 }
     76 
     77 ; Check that CEB allows indices.
     78 define i64 @f6(i64 %a, i64 %b, float %f1, float *%base, i64 %index) {
     79 ; CHECK-LABEL: f6:
     80 ; CHECK: sllg %r1, %r5, 2
     81 ; CHECK: ceb %f0, 400(%r1,%r4)
     82 ; CHECK-NEXT: je
     83 ; CHECK: lgr %r2, %r3
     84 ; CHECK: br %r14
     85   %ptr1 = getelementptr float *%base, i64 %index
     86   %ptr2 = getelementptr float *%ptr1, i64 100
     87   %f2 = load float *%ptr2
     88   %cond = fcmp oeq float %f1, %f2
     89   %res = select i1 %cond, i64 %a, i64 %b
     90   ret i64 %res
     91 }
     92 
     93 ; Check that comparisons of spilled values can use CEB rather than CEBR.
     94 define float @f7(float *%ptr0) {
     95 ; CHECK-LABEL: f7:
     96 ; CHECK: brasl %r14, foo@PLT
     97 ; CHECK: ceb {{%f[0-9]+}}, 16{{[04]}}(%r15)
     98 ; CHECK: br %r14
     99   %ptr1 = getelementptr float *%ptr0, i64 2
    100   %ptr2 = getelementptr float *%ptr0, i64 4
    101   %ptr3 = getelementptr float *%ptr0, i64 6
    102   %ptr4 = getelementptr float *%ptr0, i64 8
    103   %ptr5 = getelementptr float *%ptr0, i64 10
    104   %ptr6 = getelementptr float *%ptr0, i64 12
    105   %ptr7 = getelementptr float *%ptr0, i64 14
    106   %ptr8 = getelementptr float *%ptr0, i64 16
    107   %ptr9 = getelementptr float *%ptr0, i64 18
    108   %ptr10 = getelementptr float *%ptr0, i64 20
    109 
    110   %val0 = load float *%ptr0
    111   %val1 = load float *%ptr1
    112   %val2 = load float *%ptr2
    113   %val3 = load float *%ptr3
    114   %val4 = load float *%ptr4
    115   %val5 = load float *%ptr5
    116   %val6 = load float *%ptr6
    117   %val7 = load float *%ptr7
    118   %val8 = load float *%ptr8
    119   %val9 = load float *%ptr9
    120   %val10 = load float *%ptr10
    121 
    122   %ret = call float @foo()
    123 
    124   %cmp0 = fcmp olt float %ret, %val0
    125   %cmp1 = fcmp olt float %ret, %val1
    126   %cmp2 = fcmp olt float %ret, %val2
    127   %cmp3 = fcmp olt float %ret, %val3
    128   %cmp4 = fcmp olt float %ret, %val4
    129   %cmp5 = fcmp olt float %ret, %val5
    130   %cmp6 = fcmp olt float %ret, %val6
    131   %cmp7 = fcmp olt float %ret, %val7
    132   %cmp8 = fcmp olt float %ret, %val8
    133   %cmp9 = fcmp olt float %ret, %val9
    134   %cmp10 = fcmp olt float %ret, %val10
    135 
    136   %sel0 = select i1 %cmp0, float %ret, float 0.0
    137   %sel1 = select i1 %cmp1, float %sel0, float 1.0
    138   %sel2 = select i1 %cmp2, float %sel1, float 2.0
    139   %sel3 = select i1 %cmp3, float %sel2, float 3.0
    140   %sel4 = select i1 %cmp4, float %sel3, float 4.0
    141   %sel5 = select i1 %cmp5, float %sel4, float 5.0
    142   %sel6 = select i1 %cmp6, float %sel5, float 6.0
    143   %sel7 = select i1 %cmp7, float %sel6, float 7.0
    144   %sel8 = select i1 %cmp8, float %sel7, float 8.0
    145   %sel9 = select i1 %cmp9, float %sel8, float 9.0
    146   %sel10 = select i1 %cmp10, float %sel9, float 10.0
    147 
    148   ret float %sel10
    149 }
    150 
    151 ; Check comparison with zero.
    152 define i64 @f8(i64 %a, i64 %b, float %f) {
    153 ; CHECK-LABEL: f8:
    154 ; CHECK: ltebr %f0, %f0
    155 ; CHECK-NEXT: je
    156 ; CHECK: lgr %r2, %r3
    157 ; CHECK: br %r14
    158   %cond = fcmp oeq float %f, 0.0
    159   %res = select i1 %cond, i64 %a, i64 %b
    160   ret i64 %res
    161 }
    162