1 /* 2 * Test the CGEBRA instruction. 3 * 4 * SPDX-License-Identifier: GPL-2.0-or-later 5 */ 6 #include <assert.h> 7 #include <fenv.h> 8 #include <stdlib.h> 9 10 int main(void) 11 { 12 float r2 = 1E+300; 13 long long r1; 14 int cc; 15 16 feclearexcept(FE_ALL_EXCEPT); 17 asm("cgebra %[r1],%[m3],%[r2],%[m4]\n" 18 "ipm %[cc]\n" 19 : [r1] "=r" (r1) 20 , [cc] "=r" (cc) 21 : [m3] "i" (5) /* round toward 0 */ 22 , [r2] "f" (r2) 23 , [m4] "i" (8) /* bit 0 is set, but must be ignored; XxC is not set */ 24 : "cc"); 25 cc >>= 28; 26 27 assert(r1 == 0x7fffffffffffffffLL); 28 assert(cc == 3); 29 assert(fetestexcept(FE_ALL_EXCEPT) == (FE_INVALID | FE_INEXACT)); 30 31 return EXIT_SUCCESS; 32 } 33