1 /* Branch prediction routines for the GNU compiler.
2 Copyright (C) 2000, 2001 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
23 [1] "Branch Prediction for Free"
24 Ball and Larus; PLDI '93.
25 [2] "Static Branch Frequency and Program Profile Analysis"
26 Wu and Larus; MICRO-27.
27 [3] "Corpus-based Static Branch Prediction"
28 Calder, Grunwald, Lindsay, Martin, Mozer, and Zorn; PLDI '95.
38 #include "hard-reg-set.h"
39 #include "basic-block.h"
40 #include "insn-config.h"
51 /* Random guesstimation given names. */
52 #define PROB_NEVER (0)
53 #define PROB_VERY_UNLIKELY (REG_BR_PROB_BASE / 10 - 1)
54 #define PROB_UNLIKELY (REG_BR_PROB_BASE * 4 / 10 - 1)
55 #define PROB_EVEN (REG_BR_PROB_BASE / 2)
56 #define PROB_LIKELY (REG_BR_PROB_BASE - PROB_UNLIKELY)
57 #define PROB_VERY_LIKELY (REG_BR_PROB_BASE - PROB_VERY_UNLIKELY)
58 #define PROB_ALWAYS (REG_BR_PROB_BASE)
60 static void combine_predictions_for_insn PARAMS ((rtx, basic_block));
61 static void dump_prediction PARAMS ((enum br_predictor, int,
63 static void estimate_loops_at_level PARAMS ((struct loop *loop));
64 static void propagate_freq PARAMS ((basic_block));
65 static void estimate_bb_frequencies PARAMS ((struct loops *));
66 static void counts_to_freqs PARAMS ((void));
68 /* Information we hold about each branch predictor.
69 Filled using information from predict.def. */
72 const char *name; /* Name used in the debugging dumps. */
73 int hitrate; /* Expected hitrate used by
74 predict_insn_def call. */
77 #define DEF_PREDICTOR(ENUM, NAME, HITRATE) {NAME, HITRATE},
78 struct predictor_info predictor_info[] = {
79 #include "predict.def"
81 /* Upper bound on non-language-specific builtins. */
87 predict_insn (insn, predictor, probability)
90 enum br_predictor predictor;
92 if (!any_condjump_p (insn))
95 = gen_rtx_EXPR_LIST (REG_BR_PRED,
96 gen_rtx_CONCAT (VOIDmode,
97 GEN_INT ((int) predictor),
98 GEN_INT ((int) probability)),
102 /* Predict insn by given predictor. */
104 predict_insn_def (insn, predictor, taken)
106 enum br_predictor predictor;
107 enum prediction taken;
109 int probability = predictor_info[(int) predictor].hitrate;
111 probability = REG_BR_PROB_BASE - probability;
112 predict_insn (insn, predictor, probability);
115 /* Predict edge E with given probability if possible. */
117 predict_edge (e, predictor, probability)
120 enum br_predictor predictor;
123 last_insn = e->src->end;
125 /* We can store the branch prediction information only about
126 conditional jumps. */
127 if (!any_condjump_p (last_insn))
130 /* We always store probability of branching. */
131 if (e->flags & EDGE_FALLTHRU)
132 probability = REG_BR_PROB_BASE - probability;
134 predict_insn (last_insn, predictor, probability);
137 /* Predict edge E by given predictor if possible. */
139 predict_edge_def (e, predictor, taken)
141 enum br_predictor predictor;
142 enum prediction taken;
144 int probability = predictor_info[(int) predictor].hitrate;
147 probability = REG_BR_PROB_BASE - probability;
148 predict_edge (e, predictor, probability);
151 /* Invert all branch predictions or probability notes in the INSN. This needs
152 to be done each time we invert the condition used by the jump. */
154 invert_br_probabilities (insn)
157 rtx note = REG_NOTES (insn);
161 if (REG_NOTE_KIND (note) == REG_BR_PROB)
162 XEXP (note, 0) = GEN_INT (REG_BR_PROB_BASE - INTVAL (XEXP (note, 0)));
163 else if (REG_NOTE_KIND (note) == REG_BR_PRED)
164 XEXP (XEXP (note, 0), 1)
165 = GEN_INT (REG_BR_PROB_BASE - INTVAL (XEXP (XEXP (note, 0), 1)));
166 note = XEXP (note, 1);
170 /* Dump information about the branch prediction to the output file. */
172 dump_prediction (predictor, probability, bb)
173 enum br_predictor predictor;
182 while (e->flags & EDGE_FALLTHRU)
185 fprintf (rtl_dump_file, " %s heuristics: %.1f%%",
186 predictor_info[predictor].name,
187 probability * 100.0 / REG_BR_PROB_BASE);
191 fprintf (rtl_dump_file, " exec ",
192 bb->count, e->count, e->count * 100.0 / bb->count);
193 fprintf (rtl_dump_file, HOST_WIDEST_INT_PRINT_DEC,
194 (HOST_WIDEST_INT) bb->count);
195 fprintf (rtl_dump_file, " hit ",
196 e->count, e->count * 100.0 / bb->count);
197 fprintf (rtl_dump_file, HOST_WIDEST_INT_PRINT_DEC,
198 (HOST_WIDEST_INT) e->count);
199 fprintf (rtl_dump_file, " (%.1f%%)",
200 e->count, e->count * 100.0 / bb->count);
202 fprintf (rtl_dump_file, "\n");
205 /* Combine all REG_BR_PRED notes into single probability and attach REG_BR_PROB
206 note if not already present. Remove now useless REG_BR_PRED notes. */
208 combine_predictions_for_insn (insn, bb)
212 rtx prob_note = find_reg_note (insn, REG_BR_PROB, 0);
213 rtx *pnote = ®_NOTES (insn);
214 int best_probability = PROB_EVEN;
215 int best_predictor = END_PREDICTORS;
218 fprintf (rtl_dump_file, "Predictions for insn %i bb %i\n", INSN_UID (insn),
221 /* We implement "first match" heuristics and use probability guessed
222 by predictor with smallest index. In future we will use better
223 probability combination techniques. */
226 if (REG_NOTE_KIND (*pnote) == REG_BR_PRED)
228 int predictor = INTVAL (XEXP (XEXP (*pnote, 0), 0));
229 int probability = INTVAL (XEXP (XEXP (*pnote, 0), 1));
231 dump_prediction (predictor, probability, bb);
232 if (best_predictor > predictor)
233 best_probability = probability, best_predictor = predictor;
234 *pnote = XEXP (*pnote, 1);
237 pnote = &XEXP (*pnote, 1);
239 dump_prediction (PRED_FIRST_MATCH, best_probability, bb);
243 = gen_rtx_EXPR_LIST (REG_BR_PROB,
244 GEN_INT (best_probability), REG_NOTES (insn));
248 /* Statically estimate the probability that a branch will be taken.
249 ??? In the next revision there will be a number of other predictors added
250 from the above references. Further, each heuristic will be factored out
251 into its own function for clarity (and to facilitate the combination of
255 estimate_probability (loops_info)
256 struct loops *loops_info;
258 sbitmap *dominators, *post_dominators;
261 dominators = sbitmap_vector_alloc (n_basic_blocks, n_basic_blocks);
262 post_dominators = sbitmap_vector_alloc (n_basic_blocks, n_basic_blocks);
263 calculate_dominance_info (NULL, dominators, 0);
264 calculate_dominance_info (NULL, post_dominators, 1);
266 /* Try to predict out blocks in a loop that are not part of a
268 for (i = 0; i < loops_info->num; i++)
272 for (j = loops_info->array[i].first->index;
273 j <= loops_info->array[i].last->index;
276 if (TEST_BIT (loops_info->array[i].nodes, j))
278 int header_found = 0;
281 /* Loop branch heruistics - predict as taken an edge back to
283 for (e = BASIC_BLOCK(j)->succ; e; e = e->succ_next)
284 if (e->dest == loops_info->array[i].header)
287 predict_edge_def (e, PRED_LOOP_BRANCH, TAKEN);
289 /* Loop exit heruistics - predict as not taken an edge exiting
290 the loop if the conditinal has no loop header successors */
292 for (e = BASIC_BLOCK(j)->succ; e; e = e->succ_next)
293 if (e->dest->index <= 0
294 || !TEST_BIT (loops_info->array[i].nodes, e->dest->index))
295 predict_edge_def (e, PRED_LOOP_EXIT, NOT_TAKEN);
300 /* Attempt to predict conditional jumps using a number of heuristics.
301 For each conditional jump, we try each heuristic in a fixed order.
302 If more than one heuristic applies to a particular branch, the first
303 is used as the prediction for the branch. */
304 for (i = 0; i < n_basic_blocks; i++)
306 basic_block bb = BASIC_BLOCK (i);
307 rtx last_insn = bb->end;
311 /* If block has no sucessor, predict all possible paths to
312 it as improbable, as the block contains a call to a noreturn
313 function and thus can be executed only once. */
314 if (bb->succ == NULL)
317 for (y = 0; y < n_basic_blocks; y++)
318 if (!TEST_BIT (post_dominators[y], i))
320 for (e = BASIC_BLOCK (y)->succ; e; e = e->succ_next)
321 if (e->dest->index >= 0
322 && TEST_BIT (post_dominators[e->dest->index], i))
323 predict_edge_def (e, PRED_NORETURN, NOT_TAKEN);
327 if (GET_CODE (last_insn) != JUMP_INSN
328 || ! any_condjump_p (last_insn))
331 for (e = bb->succ; e; e = e->succ_next)
333 /* Predict edges to blocks that return immediately to be
334 improbable. These are usually used to signal error states. */
335 if (e->dest == EXIT_BLOCK_PTR
336 || (e->dest->succ && !e->dest->succ->succ_next
337 && e->dest->succ->dest == EXIT_BLOCK_PTR))
338 predict_edge_def (e, PRED_ERROR_RETURN, NOT_TAKEN);
340 /* Look for block we are guarding (ie we dominate it,
341 but it doesn't postdominate us). */
342 if (e->dest != EXIT_BLOCK_PTR
344 && TEST_BIT (dominators[e->dest->index], e->src->index)
345 && !TEST_BIT (post_dominators[e->src->index], e->dest->index))
348 /* The call heuristic claims that a guarded function call
349 is improbable. This is because such calls are often used
350 to signal exceptional situations such as printing error
352 for (insn = e->dest->head; insn != NEXT_INSN (e->dest->end);
353 insn = NEXT_INSN (insn))
354 if (GET_CODE (insn) == CALL_INSN
355 /* Constant and pure calls are hardly used to signalize
356 something exceptional. */
357 && ! CONST_CALL_P (insn))
359 predict_edge_def (e, PRED_CALL, NOT_TAKEN);
365 cond = get_condition (last_insn, &earliest);
369 /* Try "pointer heuristic."
370 A comparison ptr == 0 is predicted as false.
371 Similarly, a comparison ptr1 == ptr2 is predicted as false. */
372 switch (GET_CODE (cond))
375 if (GET_CODE (XEXP (cond, 0)) == REG
376 && REG_POINTER (XEXP (cond, 0))
377 && (XEXP (cond, 1) == const0_rtx
378 || (GET_CODE (XEXP (cond, 1)) == REG
379 && REG_POINTER (XEXP (cond, 1)))))
381 predict_insn_def (last_insn, PRED_POINTER, NOT_TAKEN);
384 if (GET_CODE (XEXP (cond, 0)) == REG
385 && REG_POINTER (XEXP (cond, 0))
386 && (XEXP (cond, 1) == const0_rtx
387 || (GET_CODE (XEXP (cond, 1)) == REG
388 && REG_POINTER (XEXP (cond, 1)))))
389 predict_insn_def (last_insn, PRED_POINTER, TAKEN);
396 /* Try "opcode heuristic."
397 EQ tests are usually false and NE tests are usually true. Also,
398 most quantities are positive, so we can make the appropriate guesses
399 about signed comparisons against zero. */
400 switch (GET_CODE (cond))
403 /* Unconditional branch. */
404 predict_insn_def (last_insn, PRED_UNCONDITIONAL,
405 cond == const0_rtx ? NOT_TAKEN : TAKEN);
410 predict_insn_def (last_insn, PRED_OPCODE, NOT_TAKEN);
414 predict_insn_def (last_insn, PRED_OPCODE, TAKEN);
417 predict_insn_def (last_insn, PRED_OPCODE, TAKEN);
420 predict_insn_def (last_insn, PRED_OPCODE, NOT_TAKEN);
424 if (XEXP (cond, 1) == const0_rtx
425 || (GET_CODE (XEXP (cond, 1)) == CONST_INT
426 && INTVAL (XEXP (cond, 1)) == -1))
427 predict_insn_def (last_insn, PRED_OPCODE, NOT_TAKEN);
431 if (XEXP (cond, 1) == const0_rtx
432 || (GET_CODE (XEXP (cond, 1)) == CONST_INT
433 && INTVAL (XEXP (cond, 1)) == -1))
434 predict_insn_def (last_insn, PRED_OPCODE, TAKEN);
442 /* Attach the combined probability to each conditional jump. */
443 for (i = 0; i < n_basic_blocks; i++)
445 rtx last_insn = BLOCK_END (i);
447 if (GET_CODE (last_insn) != JUMP_INSN
448 || ! any_condjump_p (last_insn))
450 combine_predictions_for_insn (last_insn, BASIC_BLOCK (i));
452 sbitmap_vector_free (post_dominators);
453 sbitmap_vector_free (dominators);
455 estimate_bb_frequencies (loops_info);
458 /* __builtin_expect dropped tokens into the insn stream describing
459 expected values of registers. Generate branch probabilities
460 based off these values. */
463 expected_value_to_br_prob ()
465 rtx insn, cond, ev = NULL_RTX, ev_reg = NULL_RTX;
467 for (insn = get_insns (); insn ; insn = NEXT_INSN (insn))
469 switch (GET_CODE (insn))
472 /* Look for expected value notes. */
473 if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_EXPECTED_VALUE)
475 ev = NOTE_EXPECTED_VALUE (insn);
476 ev_reg = XEXP (ev, 0);
481 /* Never propagate across labels. */
486 /* Look for insns that clobber the EV register. */
487 if (ev && reg_set_p (ev_reg, insn))
492 /* Look for simple conditional branches. If we havn't got an
493 expected value yet, no point going further. */
494 if (GET_CODE (insn) != JUMP_INSN || ev == NULL_RTX)
496 if (! any_condjump_p (insn))
501 /* Collect the branch condition, hopefully relative to EV_REG. */
502 /* ??? At present we'll miss things like
503 (expected_value (eq r70 0))
505 (set r80 (lt r70 r71))
506 (set pc (if_then_else (ne r80 0) ...))
507 as canonicalize_condition will render this to us as
509 Could use cselib to try and reduce this further. */
510 cond = XEXP (SET_SRC (PATTERN (insn)), 0);
511 cond = canonicalize_condition (insn, cond, 0, NULL, ev_reg);
513 || XEXP (cond, 0) != ev_reg
514 || GET_CODE (XEXP (cond, 1)) != CONST_INT)
517 /* Substitute and simplify. Given that the expression we're
518 building involves two constants, we should wind up with either
520 cond = gen_rtx_fmt_ee (GET_CODE (cond), VOIDmode,
521 XEXP (ev, 1), XEXP (cond, 1));
522 cond = simplify_rtx (cond);
524 /* Turn the condition into a scaled branch probability. */
525 if (cond != const_true_rtx && cond != const0_rtx)
527 predict_insn_def (insn, PRED_BUILTIN_EXPECT,
528 cond == const_true_rtx ? TAKEN : NOT_TAKEN);
532 /* This is used to carry information about basic blocks. It is
533 attached to the AUX field of the standard CFG block. */
535 typedef struct block_info_def
537 /* Estimated frequency of execution of basic_block. */
540 /* To keep queue of basic blocks to process. */
543 /* True if block already converted. */
546 /* Number of block proceeded before adding basic block to the queue. Used
547 to recognize irregular regions. */
551 /* Similar information for edges. */
552 typedef struct edge_info_def
554 /* In case edge is an loopback edge, the probability edge will be reached
555 in case header is. Estimated number of iterations of the loop can be
556 then computed as 1 / (1 - back_edge_prob). */
557 double back_edge_prob;
558 /* True if the edge is an loopback edge in the natural loop. */
562 #define BLOCK_INFO(B) ((block_info) (B)->aux)
563 #define EDGE_INFO(E) ((edge_info) (E)->aux)
565 /* Helper function for estimate_bb_frequencies.
566 Propagate the frequencies for loops headed by HEAD. */
568 propagate_freq (head)
571 basic_block bb = head;
572 basic_block last = bb;
577 BLOCK_INFO (head)->frequency = 1;
578 for (; bb; bb = nextbb)
580 double cyclic_probability = 0, frequency = 0;
582 nextbb = BLOCK_INFO (bb)->next;
583 BLOCK_INFO (bb)->next = NULL;
585 /* Compute frequency of basic block. */
588 for (e = bb->pred; e; e = e->pred_next)
589 if (!BLOCK_INFO (e->src)->visited && !EDGE_INFO (e)->back_edge)
592 /* We didn't proceeded all predecesors of edge e yet. These may
593 be waiting in the queue or we may hit irreducible region.
595 To avoid infinite looping on irrecudible regions, count number
596 of block proceeded at the time basic block has been queued. In the
597 case number didn't changed, we've hit irreducible region and we
598 forget the backward edge. This can increase time complexity
599 by the number of irreducible blocks, but in same way standard the
600 loop does, so it should not result in noticeable slowodwn.
602 Alternativly we may distinquish backward and cross edges in the
603 DFS tree by preprocesing pass and ignore existence of non-loop
605 if (e && BLOCK_INFO (bb)->nvisited != nvisited)
610 BLOCK_INFO (last)->next = e->dest;
611 BLOCK_INFO (last)->nvisited = nvisited;
615 else if (e && rtl_dump_file)
616 fprintf (rtl_dump_file, "Irreducible region hit, ignoring edge to bb %i\n",
619 for (e = bb->pred; e; e = e->pred_next)
620 if (EDGE_INFO (e)->back_edge)
621 cyclic_probability += EDGE_INFO (e)->back_edge_prob;
622 else if (BLOCK_INFO (e->src)->visited)
623 frequency += (e->probability
624 * BLOCK_INFO (e->src)->frequency /
627 if (cyclic_probability > 1.0 - 1.0 / REG_BR_PROB_BASE)
628 cyclic_probability = 1.0 - 1.0 / REG_BR_PROB_BASE;
630 BLOCK_INFO (bb)->frequency = frequency / (1 - cyclic_probability);
633 BLOCK_INFO (bb)->visited = 1;
635 /* Compute back edge frequencies. */
636 for (e = bb->succ; e; e = e->succ_next)
638 EDGE_INFO (e)->back_edge_prob = (e->probability
639 * BLOCK_INFO (bb)->frequency
642 /* Propagate to succesor blocks. */
643 for (e = bb->succ; e; e = e->succ_next)
644 if (!EDGE_INFO (e)->back_edge
645 && !BLOCK_INFO (e->dest)->visited
646 && !BLOCK_INFO (e->dest)->next && e->dest != last)
651 BLOCK_INFO (last)->next = e->dest;
652 BLOCK_INFO (last)->nvisited = nvisited;
659 /* Estimate probabilities of the loopback edges in loops at same nest level. */
661 estimate_loops_at_level (first_loop)
662 struct loop *first_loop;
664 struct loop *l, *loop = first_loop;
666 for (loop = first_loop; loop; loop = loop->next)
671 estimate_loops_at_level (loop->inner);
673 /* find current loop back edge and mark it. */
674 for (e = loop->latch->succ; e->dest != loop->header; e = e->succ_next);
676 EDGE_INFO (e)->back_edge = 1;
678 /* In case loop header is shared, ensure that it is the last one sharing
679 same header, so we avoid redundant work. */
682 for (l = loop->next; l; l = l->next)
683 if (l->header == loop->header)
689 /* Now merge all nodes of all loops with given header as not visited. */
690 for (l = loop->shared ? first_loop : loop; l != loop->next; l = l->next)
691 if (loop->header == l->header)
692 EXECUTE_IF_SET_IN_SBITMAP (l->nodes, 0, n,
693 BLOCK_INFO (BASIC_BLOCK (n))->visited =
695 propagate_freq (loop->header);
699 /* Convert counts measured by profile driven feedback to frequencies. */
703 HOST_WIDEST_INT count_max = 1;
706 for (i = 0; i < n_basic_blocks; i++)
707 if (BASIC_BLOCK (i)->count > count_max)
708 count_max = BASIC_BLOCK (i)->count;
710 for (i = -2; i < n_basic_blocks; i++)
714 bb = ENTRY_BLOCK_PTR;
718 bb = BASIC_BLOCK (i);
719 bb->frequency = ((bb->count * BB_FREQ_MAX + count_max / 2)
724 /* Estimate basic blocks frequency by given branch probabilities. */
726 estimate_bb_frequencies (loops)
735 if (flag_branch_probabilities)
741 /* Fill in the probability values in flowgraph based on the REG_BR_PROB
743 for (i = 0; i < n_basic_blocks; i++)
745 rtx last_insn = BLOCK_END (i);
747 edge fallthru, branch;
749 if (GET_CODE (last_insn) != JUMP_INSN || !any_condjump_p (last_insn)
750 /* Avoid handling of conditionals jump jumping to fallthru edge. */
751 || BASIC_BLOCK (i)->succ->succ_next == NULL)
753 /* We can predict only conditional jumps at the moment.
754 Expect each edge to be equall probable.
755 ?? In future we want to make abnormal edges improbable. */
759 for (e = BASIC_BLOCK (i)->succ; e; e = e->succ_next)
762 if (e->probability != 0)
766 for (e = BASIC_BLOCK (i)->succ; e; e = e->succ_next)
767 e->probability = (REG_BR_PROB_BASE + nedges / 2) / nedges;
771 probability = INTVAL (XEXP (find_reg_note (last_insn,
772 REG_BR_PROB, 0), 0));
773 fallthru = BASIC_BLOCK (i)->succ;
774 if (!fallthru->flags & EDGE_FALLTHRU)
775 fallthru = fallthru->succ_next;
776 branch = BASIC_BLOCK (i)->succ;
777 if (branch->flags & EDGE_FALLTHRU)
778 branch = branch->succ_next;
780 branch->probability = probability;
781 fallthru->probability = REG_BR_PROB_BASE - probability;
784 ENTRY_BLOCK_PTR->succ->probability = REG_BR_PROB_BASE;
786 /* Set up block info for each basic block. */
787 bi = (block_info) xcalloc ((n_basic_blocks + 2), sizeof (*bi));
788 ei = (edge_info) xcalloc ((n_edges), sizeof (*ei));
789 for (i = -2; i < n_basic_blocks; i++)
795 bb = ENTRY_BLOCK_PTR;
799 bb = BASIC_BLOCK (i);
800 bb->aux = bi + i + 2;
801 BLOCK_INFO (bb)->visited = 1;
802 for (e = bb->succ; e; e = e->succ_next)
804 e->aux = ei + edgenum, edgenum++;
805 EDGE_INFO (e)->back_edge_prob = ((double) e->probability
809 /* First compute probabilities locally for each loop from innermost
810 to outermost to examine probabilities for back edges. */
811 estimate_loops_at_level (loops->tree);
813 /* Now fake loop around whole function to finalize probabilities. */
814 for (i = 0; i < n_basic_blocks; i++)
815 BLOCK_INFO (BASIC_BLOCK (i))->visited = 0;
816 BLOCK_INFO (ENTRY_BLOCK_PTR)->visited = 0;
817 BLOCK_INFO (EXIT_BLOCK_PTR)->visited = 0;
818 propagate_freq (ENTRY_BLOCK_PTR);
820 for (i = 0; i < n_basic_blocks; i++)
821 if (BLOCK_INFO (BASIC_BLOCK (i))->frequency > freq_max)
822 freq_max = BLOCK_INFO (BASIC_BLOCK (i))->frequency;
823 for (i = -2; i < n_basic_blocks; i++)
827 bb = ENTRY_BLOCK_PTR;
831 bb = BASIC_BLOCK (i);
832 bb->frequency = (BLOCK_INFO (bb)->frequency * BB_FREQ_MAX / freq_max