1 /* { dg-do run } */ 2 /* { dg-options "-O" } */ 3 /* { dg-require-effective-target int32plus } */ 4 5 extern void abort (void); 6 typedef unsigned int u_int32; 7 8 typedef struct { 9 union {u_int32 Xl_ui;} Ul_i; 10 union {u_int32 Xl_uf;} Ul_f; 11 } l_fp; 12 13 void dolfptoa(short ndec)14dolfptoa (short ndec) 15 { 16 l_fp work, ftmp; 17 18 work.Ul_i.Xl_ui = 0; 19 work.Ul_f.Xl_uf = 0x535f3d8; 20 21 while (ndec > 0) 22 { 23 u_int32 lo_tmp; 24 u_int32 hi_tmp; 25 26 ndec--; 27 work.Ul_i.Xl_ui = 0; 28 work.Ul_i.Xl_ui <<= 1; 29 if ((work.Ul_f.Xl_uf) & 0x80000000) 30 (work.Ul_i.Xl_ui) |= 0x1; 31 (work.Ul_f.Xl_uf) <<= 1; 32 33 ftmp = work; 34 (work.Ul_i.Xl_ui) <<= 1; 35 if ((work.Ul_f.Xl_uf) & 0x80000000) 36 (work.Ul_i.Xl_ui) |= 0x1; 37 (work.Ul_f.Xl_uf) <<= 1; 38 39 (work.Ul_i.Xl_ui) <<= 1; 40 if ((work.Ul_f.Xl_uf) & 0x80000000) 41 (work.Ul_i.Xl_ui) |= 0x1; 42 (work.Ul_f.Xl_uf) <<= 1; 43 44 lo_tmp = ((work.Ul_f.Xl_uf) & 0xffff) + ((ftmp.Ul_f.Xl_uf) & 0xffff); 45 hi_tmp = (((work.Ul_f.Xl_uf) >> 16) & 0xffff) 46 + (((ftmp.Ul_f.Xl_uf) >> 16) & 0xffff); 47 48 if (lo_tmp & 0x10000) 49 hi_tmp++; 50 51 (work.Ul_f.Xl_uf) = ((hi_tmp & 0xffff) << 16) | (lo_tmp & 0xffff); 52 (work.Ul_i.Xl_ui) += (ftmp.Ul_i.Xl_ui); 53 54 if (hi_tmp & 0x10000) 55 (work.Ul_i.Xl_ui)++; 56 57 58 if (!(work.Ul_i.Xl_ui < 10)) 59 abort (); 60 } 61 } 62 main()63int main() 64 { 65 dolfptoa(6); 66 return 0; 67 } 68