This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
ia64 branch prediction cleanup
- To: gcc-patches at gcc dot gnu dot org
- Subject: ia64 branch prediction cleanup
- From: Richard Henderson <rth at cygnus dot com>
- Date: Wed, 31 May 2000 17:11:14 -0700
Uses current_output_insn that I added yesterday.
r~
* config/ia64/ia64-protos.h (ia64_expand_prediction): Remove.
* config/ia64/ia64.c (ia64_expand_prediction): Move code ...
(ia64_print_operand) [+]: ... here. Use current_output_insn.
* config/ia64/ia64.h (PRINT_OPERAND_PUNCT_VALID_P): New.
* config/ia64/ia64.md (all branch/call patterns): Use %+.
Index: ia64-protos.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/ia64/ia64-protos.h,v
retrieving revision 1.6
diff -c -p -d -r1.6 ia64-protos.h
*** ia64-protos.h 2000/05/09 06:17:35 1.6
--- ia64-protos.h 2000/06/01 00:07:55
*************** extern enum reg_class ia64_secondary_rel
*** 61,67 ****
enum machine_mode,
rtx));
extern void ia64_reorg PARAMS((rtx));
- extern const char *ia64_expand_prediction PARAMS((rtx, const char *));
#endif /* RTX_CODE */
#ifdef TREE_CODE
--- 61,66 ----
Index: ia64.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/ia64/ia64.c,v
retrieving revision 1.18
diff -c -p -d -r1.18 ia64.c
*** ia64.c 2000/05/25 15:21:51 1.18
--- ia64.c 2000/06/01 00:07:55
*************** ia64_print_operand (file, x, code)
*** 1714,1721 ****
{
switch (code)
{
- /* XXX Add other codes here. */
-
case 0:
/* Handled below. */
break;
--- 1714,1719 ----
*************** ia64_print_operand (file, x, code)
*** 1840,1845 ****
--- 1838,1873 ----
output_operand_lossage ("invalid %%r value");
return;
+ case '+':
+ {
+ const char *which;
+
+ /* For conditional branches, returns or calls, substitute
+ sptk, dptk, dpnt, or spnt for %s. */
+ x = find_reg_note (current_output_insn, REG_BR_PROB, 0);
+ if (x)
+ {
+ int pred_val = INTVAL (XEXP (x, 0));
+
+ /* Guess top and bottom 10% statically predicted. */
+ if (pred_val < REG_BR_PROB_BASE / 10)
+ which = ".spnt";
+ else if (pred_val < REG_BR_PROB_BASE / 2)
+ which = ".dpnt";
+ else if (pred_val < REG_BR_PROB_BASE * 9 / 10)
+ which = ".dptk";
+ else
+ which = ".sptk";
+ }
+ else if (GET_CODE (current_output_insn) == CALL_INSN)
+ which = ".sptk";
+ else
+ which = ".dptk";
+
+ fputs (which, file);
+ return;
+ }
+
default:
output_operand_lossage ("ia64_print_operand: unknown code");
return;
*************** ia64_print_operand (file, x, code)
*** 1871,1918 ****
}
return;
- }
-
- /* For conditional branches, returns or calls, substitute
- sptk, dptk, dpnt, or spnt for %s. */
-
- const char *
- ia64_expand_prediction (insn, template)
- rtx insn;
- const char *template;
- {
- static char const pred_name[4][5] = {
- "spnt", "dpnt", "dptk", "sptk"
- };
- static char new_template[64];
-
- int pred_val, pred_which;
- rtx note;
-
- note = find_reg_note (insn, REG_BR_PROB, 0);
- if (note)
- {
- pred_val = INTVAL (XEXP (note, 0));
-
- /* Guess top and bottom 10% statically predicted. */
- if (pred_val < REG_BR_PROB_BASE / 10)
- pred_which = 0;
- else if (pred_val < REG_BR_PROB_BASE / 2)
- pred_which = 1;
- else if (pred_val < REG_BR_PROB_BASE * 9 / 10)
- pred_which = 2;
- else
- pred_which = 3;
- }
- else
- pred_which = 2;
-
- if (strlen (template) >= sizeof (new_template) - 3)
- abort ();
-
- sprintf (new_template, template, pred_name[pred_which]);
-
- return new_template;
}
--- 1899,1904 ----
Index: ia64.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/ia64/ia64.h,v
retrieving revision 1.15
diff -c -p -d -r1.15 ia64.h
*** ia64.h 2000/05/25 15:21:51 1.15
--- ia64.h 2000/06/01 00:07:55
*************** do { \
*** 2469,2475 ****
/* ??? Keep this around for now, as we might need it later. */
! /* #define PRINT_OPERAND_PUNCT_VALID_P(CODE) */
/* A C compound statement to output to stdio stream STREAM the assembler syntax
for an instruction operand that is a memory reference whose address is X. X
--- 2469,2475 ----
/* ??? Keep this around for now, as we might need it later. */
! #define PRINT_OPERAND_PUNCT_VALID_P(CODE) ((CODE) == '+')
/* A C compound statement to output to stdio stream STREAM the assembler syntax
for an instruction operand that is a memory reference whose address is X. X
Index: ia64.md
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/ia64/ia64.md,v
retrieving revision 1.14
diff -c -p -d -r1.14 ia64.md
*** ia64.md 2000/05/25 15:21:51 1.14
--- ia64.md 2000/06/01 00:07:55
***************
*** 2162,2168 ****
(label_ref (match_operand 2 "" ""))
(pc)))]
""
! "* return ia64_expand_prediction (insn, \"(%%J0) br.cond.%s %%l2\");"
[(set_attr "type" "B")
(set_attr "predicable" "no")])
--- 2162,2168 ----
(label_ref (match_operand 2 "" ""))
(pc)))]
""
! "(%J0) br.cond%+ %l2"
[(set_attr "type" "B")
(set_attr "predicable" "no")])
***************
*** 2174,2180 ****
(pc)
(label_ref (match_operand 2 "" ""))))]
""
! "* return ia64_expand_prediction (insn, \"(%%j0) br.cond.%s %%l2\");"
[(set_attr "type" "B")
(set_attr "predicable" "no")])
--- 2174,2180 ----
(pc)
(label_ref (match_operand 2 "" ""))))]
""
! "(%j0) br.cond%+ %l2"
[(set_attr "type" "B")
(set_attr "predicable" "no")])
***************
*** 2717,2730 ****
(match_operand 1 "" ""))
(clobber (match_operand:DI 2 "register_operand" "=b"))]
""
! "*
! {
! operands[3] = current_insn_predicate;
! if (operands[3] != NULL_RTX)
! return ia64_expand_prediction (insn, \"(%%J3) br.call.%s.many %2 = %0\");
! else
! return \"br.call.sptk.many %2 = %0\";
! }"
[(set_attr "type" "B")])
(define_insn "*call_internal1"
--- 2717,2723 ----
(match_operand 1 "" ""))
(clobber (match_operand:DI 2 "register_operand" "=b"))]
""
! "br.call%+.many %2 = %0"
[(set_attr "type" "B")])
(define_insn "*call_internal1"
***************
*** 2733,2746 ****
(use (reg:DI 1))
(clobber (match_operand:DI 2 "register_operand" "=b"))]
""
! "*
! {
! operands[3] = current_insn_predicate;
! if (operands[3] != NULL_RTX)
! return ia64_expand_prediction (insn, \"(%%J3) br.call.%s.many %2 = %0\");
! else
! return \"br.call.sptk.many %2 = %0\";
! }"
[(set_attr "type" "B")])
;; Subroutine call instruction returning a value. Operand 0 is the hard
--- 2726,2732 ----
(use (reg:DI 1))
(clobber (match_operand:DI 2 "register_operand" "=b"))]
""
! "br.call%+.many %2 = %0"
[(set_attr "type" "B")])
;; Subroutine call instruction returning a value. Operand 0 is the hard
***************
*** 2940,2953 ****
(match_operand 2 "" "")))
(clobber (match_operand:DI 3 "register_operand" "=b"))]
""
! "*
! {
! operands[4] = current_insn_predicate;
! if (operands[4] != NULL_RTX)
! return ia64_expand_prediction (insn, \"(%%J4) br.call.%s.many %3 = %1\");
! else
! return \"br.call.sptk.many %3 = %1\";
! }"
[(set_attr "type" "B")])
(define_insn "*call_value_internal1"
--- 2926,2932 ----
(match_operand 2 "" "")))
(clobber (match_operand:DI 3 "register_operand" "=b"))]
""
! "br.call%+.many %3 = %1"
[(set_attr "type" "B")])
(define_insn "*call_value_internal1"
***************
*** 2957,2970 ****
(use (reg:DI 1))
(clobber (match_operand:DI 3 "register_operand" "=b"))]
""
! "*
! {
! operands[4] = current_insn_predicate;
! if (operands[4] != NULL_RTX)
! return ia64_expand_prediction (insn, \"(%%J4) br.call.%s.many %3 = %1\");
! else
! return \"br.call.sptk.many %3 = %1\";
! }"
[(set_attr "type" "B")])
(define_insn "*call_multiple_values_internal1"
--- 2936,2942 ----
(use (reg:DI 1))
(clobber (match_operand:DI 3 "register_operand" "=b"))]
""
! "br.call%+.many %3 = %1"
[(set_attr "type" "B")])
(define_insn "*call_multiple_values_internal1"
***************
*** 2975,2988 ****
(use (reg:DI 1))
(clobber (match_operand:DI 4 "register_operand" "=b"))])]
""
! "*
! {
! operands[5] = current_insn_predicate;
! if (operands[5] != NULL_RTX)
! return ia64_expand_prediction (insn, \"(%%J5) br.call.%s.many %4 = %2\");
! else
! return \"br.call.sptk.many %4 = %2\";
! }"
[(set_attr "type" "B")])
;; Call subroutine returning any type.
--- 2947,2953 ----
(use (reg:DI 1))
(clobber (match_operand:DI 4 "register_operand" "=b"))])]
""
! "br.call%+.many %4 = %2"
[(set_attr "type" "B")])
;; Call subroutine returning any type.
***************
*** 3035,3041 ****
(return)
(pc)))]
"ia64_direct_return ()"
! "* return ia64_expand_prediction (insn, \"(%%J0) br.ret.%s.many rp\");"
[(set_attr "type" "B")
(set_attr "predicable" "no")])
--- 3000,3006 ----
(return)
(pc)))]
"ia64_direct_return ()"
! "(%%J0) br.ret%+.many rp"
[(set_attr "type" "B")
(set_attr "predicable" "no")])
***************
*** 3047,3053 ****
(pc)
(return)))]
"ia64_direct_return ()"
! "* return ia64_expand_prediction (insn, \"(%%j0) br.ret.%s.many rp\");"
[(set_attr "type" "B")
(set_attr "predicable" "no")])
--- 3012,3018 ----
(pc)
(return)))]
"ia64_direct_return ()"
! "(%%j0) br.ret%+.many rp"
[(set_attr "type" "B")
(set_attr "predicable" "no")])