qbe

Internal scc patchset buffer for QBE
Log | Files | Refs | README | LICENSE

isel2.ssa (2421B)


      1 # tests that NaN is handled properly by
      2 # floating point comparisons
      3 
      4 export function w $lt(d %x, d %y) {
      5 @start
      6 	%r =w cltd %x, %y
      7 	ret %r
      8 }
      9 
     10 export function w $le(d %x, d %y) {
     11 @start
     12 	%r =w cled %x, %y
     13 	ret %r
     14 }
     15 
     16 export function w $gt(d %x, d %y) {
     17 @start
     18 	%r =w cgtd %x, %y
     19 	ret %r
     20 }
     21 
     22 export function w $ge(d %x, d %y) {
     23 @start
     24 	%r =w cged %x, %y
     25 	ret %r
     26 }
     27 
     28 export function w $eq1(d %x, d %y) {
     29 @start
     30 	%r =w ceqd %x, %y
     31 	ret %r
     32 }
     33 
     34 export function w $eq2(d %x, d %y) {
     35 @start
     36 	%r =w ceqd %x, %y
     37 	jnz %r, @true, @false
     38 @true
     39 	ret 1
     40 @false
     41 	ret 0
     42 }
     43 
     44 export function w $eq3(d %x, d %y) {
     45 @start
     46 	%r =w ceqd %x, %y
     47 	jnz %r, @true, @false
     48 @true
     49 	ret %r
     50 @false
     51 	ret 0
     52 }
     53 
     54 export function w $ne1(d %x, d %y) {
     55 @start
     56 	%r =w cned %x, %y
     57 	ret %r
     58 }
     59 
     60 export function w $ne2(d %x, d %y) {
     61 @start
     62 	%r =w cned %x, %y
     63 	jnz %r, @true, @false
     64 @true
     65 	ret 1
     66 @false
     67 	ret 0
     68 }
     69 
     70 export function w $ne3(d %x, d %y) {
     71 @start
     72 	%r =w cned %x, %y
     73 	jnz %r, @true, @false
     74 @true
     75 	ret %r
     76 @false
     77 	ret 0
     78 }
     79 
     80 export function w $o(d %x, d %y) {
     81 @start
     82 	%r =w cod %x, %y
     83 	ret %r
     84 }
     85 
     86 export function w $uo(d %x, d %y) {
     87 @start
     88 	%r =w cuod %x, %y
     89 	ret %r
     90 }
     91 
     92 # >>> driver
     93 # #include <math.h>
     94 # extern int lt(double, double);
     95 # extern int le(double, double);
     96 # extern int gt(double, double);
     97 # extern int ge(double, double);
     98 # extern int eq1(double, double);
     99 # extern int eq2(double, double);
    100 # extern int eq3(double, double);
    101 # extern int ne1(double, double);
    102 # extern int ne2(double, double);
    103 # extern int ne3(double, double);
    104 # extern int o(double, double);
    105 # extern int uo(double, double);
    106 # int main(void) {
    107 # 	/*     LessThan     Equal        GreaterThan   Unordered */
    108 # 	return !lt(0, 1)  + lt(0, 0)   + lt(1, 0)    + lt(NAN, NAN)
    109 # 	     + !le(0, 1)  + !le(0, 0)  + le(1, 0)    + le(NAN, NAN)
    110 # 	     + gt(0, 1)   + gt(0, 0)   + !gt(1, 0)   + gt(NAN, NAN)
    111 # 	     + ge(0, 1)   + !ge(0, 0)  + !ge(1, 0)   + ge(NAN, NAN)
    112 # 	     + eq1(0, 1)  + !eq1(0, 0) + eq1(1, 0)   + eq1(NAN, NAN)
    113 # 	     + eq2(0, 1)  + !eq2(0, 0) + eq2(1, 0)   + eq2(NAN, NAN)
    114 # 	     + eq3(0, 1)  + !eq3(0, 0) + eq3(1, 0)   + eq3(NAN, NAN)
    115 # 	     + !ne1(0, 1) + ne1(0, 0)  + !ne1(1, 0)  + !ne1(NAN, NAN)
    116 # 	     + !ne2(0, 1) + ne2(0, 0)  + !ne2(1, 0)  + !ne2(NAN, NAN)
    117 # 	     + !ne3(0, 1) + ne3(0, 0)  + !ne3(1, 0)  + !ne3(NAN, NAN)
    118 # 	     + !o(0, 1)   + !o(0, 0)   + !o(1, 0)    + o(NAN, NAN)
    119 # 	     + uo(0, 1)   + uo(0, 0)   + uo(1, 0)    + !uo(NAN, NAN)
    120 # 	     ;
    121 # }
    122 # <<<