PR middle-end/85602 - -Wsizeof-pointer-memaccess for strncat with size of source
[official-gcc.git] / gcc / testsuite / gcc.dg / pr42250.c
blob3ba8e8413e7d50e74565f4709d954e98488c6be9
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fipa-struct-reorg" } */
4 extern double log10 (double __x);
5 extern double ceil (double __x);
6 extern double floor (double __x);
7 extern void free (void *__ptr);
8 extern void *my_malloc (unsigned int);
9 extern int num_rr_nodes;
10 static float get_cblock_trans (int *num_inputs_to_cblock,
11 int max_inputs_to_cblock,
12 float trans_cblock_to_lblock_buf,
13 float trans_sram_bit);
14 static float trans_per_mux (int num_inputs, float trans_sram_bit);
15 void
16 count_routing_transistors (int num_switch, float R_minW_nmos,
17 float R_minW_pmos)
19 int *num_inputs_to_cblock;
20 int iswitch, i, j, iseg, max_inputs_to_cblock;
21 float input_cblock_trans;
22 const float trans_sram_bit = 6.;
23 float trans_cblock_to_lblock_buf;
24 input_cblock_trans =
25 get_cblock_trans (num_inputs_to_cblock, max_inputs_to_cblock,
26 trans_cblock_to_lblock_buf, trans_sram_bit);
29 static float
30 get_cblock_trans (int *num_inputs_to_cblock, int max_inputs_to_cblock,
31 float trans_cblock_to_lblock_buf, float trans_sram_bit)
33 float *trans_per_cblock;
34 float trans_count;
35 int i, num_inputs;
37 trans_per_cblock =
38 (float *) my_malloc ((max_inputs_to_cblock + 1) * sizeof (float));
39 for (i = 1; i <= max_inputs_to_cblock; i++)
40 trans_per_cblock[i] =
41 trans_per_mux (i, trans_sram_bit) + trans_cblock_to_lblock_buf;
42 for (i = 0; i < num_rr_nodes; i++)
44 num_inputs = num_inputs_to_cblock[i];
45 trans_count += trans_per_cblock[num_inputs];
47 free (trans_per_cblock);
48 return (trans_count);
51 static float
52 trans_per_mux (int num_inputs, float trans_sram_bit)
54 int nlevels, ilevel, current_inps;
55 float ntrans = 0;
57 if (num_inputs <= 1)
58 return (0);
59 nlevels = ceil (log10 (num_inputs) / log10 (2.) - 0.00001);
60 current_inps = num_inputs;
61 for (ilevel = 1; ilevel <= nlevels; ilevel++)
63 ntrans += 2 * floor (current_inps / 2.);
64 current_inps = ceil (current_inps / 2.);
66 ntrans += trans_sram_bit * nlevels;
67 return (ntrans);