1 /* See if various BMI2 instructions give expected results */
15 void test_adox_adcx(uint32_t in_c
, uint32_t in_o
, REG adcx_operand
, REG adox_operand
)
18 REG out_adcx
, out_adox
;
20 asm("pushf; pop %0" : "=r"(flags
));
21 flags
&= ~(CC_C
| CC_O
);
22 flags
|= (in_c
? CC_C
: 0);
23 flags
|= (in_o
? CC_O
: 0);
25 out_adcx
= adcx_operand
;
26 out_adox
= adox_operand
;
31 : "+r" (flags
), "+r" (out_adcx
), "+r" (out_adox
)
32 : "r" ((REG
)-1), "0" (flags
), "1" (out_adcx
), "2" (out_adox
));
34 assert(out_adcx
== in_c
+ adcx_operand
- 1);
35 assert(out_adox
== in_o
+ adox_operand
- 1);
36 assert(!!(flags
& CC_C
) == (in_c
|| adcx_operand
));
37 assert(!!(flags
& CC_O
) == (in_o
|| adox_operand
));
40 void test_adcx_adox(uint32_t in_c
, uint32_t in_o
, REG adcx_operand
, REG adox_operand
)
43 REG out_adcx
, out_adox
;
45 asm("pushf; pop %0" : "=r"(flags
));
46 flags
&= ~(CC_C
| CC_O
);
47 flags
|= (in_c
? CC_C
: 0);
48 flags
|= (in_o
? CC_O
: 0);
50 out_adcx
= adcx_operand
;
51 out_adox
= adox_operand
;
56 : "+r" (flags
), "+r" (out_adcx
), "+r" (out_adox
)
57 : "r" ((REG
)-1), "0" (flags
), "1" (out_adcx
), "2" (out_adox
));
59 assert(out_adcx
== in_c
+ adcx_operand
- 1);
60 assert(out_adox
== in_o
+ adox_operand
- 1);
61 assert(!!(flags
& CC_C
) == (in_c
|| adcx_operand
));
62 assert(!!(flags
& CC_O
) == (in_o
|| adox_operand
));
65 int main(int argc
, char *argv
[]) {
66 /* try all combinations of input CF, input OF, CF from op1+op2, OF from op2+op1 */
68 for (i
= 0; i
<= 15; i
++) {
70 test_adcx_adox(!!(i
& 1), !!(i
& 2), !!(i
& 4), !!(i
& 8));
71 test_adox_adcx(!!(i
& 1), !!(i
& 2), !!(i
& 4), !!(i
& 8));