blob: 5f9eef9d097c641cbcb6dc33344f712e2bc05bf1 [file] [log] [blame]
Bill Buzbee7c58bd42016-01-20 20:46:01 +00001%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 movzbl 3(rPC), %ecx # ecx<- CC
20 movzbl 2(rPC), %eax # eax<- BB
21 movs${suff} VREG_ADDRESS(%eax), %xmm0
22 xor %eax, %eax
23 ucomis${suff} VREG_ADDRESS(%ecx), %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 incl %eax
29 jmp .L${opcode}_finish
30.L${opcode}_nan_is_neg:
31.L${opcode}_less:
32 decl %eax
33.L${opcode}_finish:
Serguei Katkov05dfaaa2016-01-28 08:21:26 +060034 SET_VREG %eax, rINST
Bill Buzbee7c58bd42016-01-20 20:46:01 +000035 ADVANCE_PC_FETCH_AND_GOTO_NEXT 2