1%default {"suff":"d","nanval":"pos"}
2/*
3 * Compare two floating-point values.  Puts 0, 1, or -1 into the
4 * destination register based on the results of the comparison.
5 *
6 * int compare(x, y) {
7 *     if (x == y) {
8 *         return 0;
9 *     } else if (x < y) {
10 *         return -1;
11 *     } else if (x > y) {
12 *         return 1;
13 *     } else {
14 *         return nanval ? 1 : -1;
15 *     }
16 * }
17 */
18    /* op vAA, vBB, vCC */
19    movzbq  3(rPC), %rcx                    # ecx<- CC
20    movzbq  2(rPC), %rax                    # eax<- BB
21    movs${suff} VREG_ADDRESS(%rax), %xmm0
22    xor     %eax, %eax
23    ucomis${suff} VREG_ADDRESS(%rcx), %xmm0
24    jp      .L${opcode}_nan_is_${nanval}
25    je      .L${opcode}_finish
26    jb      .L${opcode}_less
27.L${opcode}_nan_is_pos:
28    addb    $$1, %al
29    jmp     .L${opcode}_finish
30.L${opcode}_nan_is_neg:
31.L${opcode}_less:
32    movl    $$-1, %eax
33.L${opcode}_finish:
34    SET_VREG %eax, rINSTq
35    ADVANCE_PC_FETCH_AND_GOTO_NEXT 2
36