[PATCH] Improve handling of COND_EXECs in haifa_classify_insn.
Alexander Monakov
monoid@ispras.ru
Mon Oct 1 16:33:00 GMT 2007
Hi.
This patch has been in sel-sched branch for a while. It makes
haifa_classify_insn look into predicate and code parts of COND_EXEC to
decide whether it traps or not, instead of assuming that all COND_EXECs
trap. It also factors code duplication in handling of PARALLELs (by using
recursion).
Bootstrapped and regtested on x64_64 with --disable-multilib and on ia64.
:ADDPATCH scheduler:
Thanks.
* gcc/haifa-sched.c (haifa_classify_insn): Rename to ...
(haifa_classify_insn_pat): ... this. Re-structure. Improve handling
of COND_EXECs. Use it ...
* gcc/sched-int.h (haifa_classify_insn): ... Here. Reimplement.
--- gcc/haifa-sched.c (revision 31645)
+++ gcc/haifa-sched.c (local)
@@ -405,8 +405,8 @@ may_trap_exp (const_rtx x, int is_store)
}
}
-/* Classifies insn for the purpose of verifying that it can be
- moved speculatively, by examining it's patterns, returning:
+/* Classifies pattern of an insn for the purpose of verifying that it can
be
+ moved speculatively, by examining it, returning:
TRAP_RISKY: store, or risky non-load insn (e.g. division by variable).
TRAP_FREE: non-load insn.
IFREE: load from a globally safe location.
@@ -415,9 +415,8 @@ may_trap_exp (const_rtx x, int is_store)
being either PFREE or PRISKY. */
int
-haifa_classify_insn (const_rtx insn)
+haifa_classify_insn_pat (rtx pat)
{
- rtx pat = PATTERN (insn);
int tmp_class = TRAP_FREE;
int insn_class = TRAP_FREE;
enum rtx_code code;
@@ -428,31 +427,7 @@ haifa_classify_insn (const_rtx insn)
for (i = len - 1; i >= 0; i--)
{
- code = GET_CODE (XVECEXP (pat, 0, i));
- switch (code)
- {
- case CLOBBER:
- /* Test if it is a 'store'. */
- tmp_class = may_trap_exp (XEXP (XVECEXP (pat, 0, i), 0), 1);
- break;
- case SET:
- /* Test if it is a store. */
- tmp_class = may_trap_exp (SET_DEST (XVECEXP (pat, 0, i)), 1);
- if (tmp_class == TRAP_RISKY)
- break;
- /* Test if it is a load. */
- tmp_class
- = WORST_CLASS (tmp_class,
- may_trap_exp (SET_SRC (XVECEXP (pat, 0, i)),
- 0));
- break;
- case COND_EXEC:
- case TRAP_IF:
- tmp_class = TRAP_RISKY;
- break;
- default:
- ;
- }
+ tmp_class = haifa_classify_insn_pat (XVECEXP (pat, 0, i));
insn_class = WORST_CLASS (insn_class, tmp_class);
if (insn_class == TRAP_RISKY || insn_class == IRISKY)
break;
@@ -478,6 +453,12 @@ haifa_classify_insn (const_rtx insn)
may_trap_exp (SET_SRC (pat), 0));
break;
case COND_EXEC:
+ tmp_class = haifa_classify_insn_pat (COND_EXEC_CODE (pat));
+ if (tmp_class == TRAP_RISKY)
+ break;
+ tmp_class = WORST_CLASS (tmp_class,
+ may_trap_exp (COND_EXEC_TEST (pat), 0));
+ break;
case TRAP_IF:
tmp_class = TRAP_RISKY;
break;
--- gcc/sched-int.h (revision 31645)
+++ gcc/sched-int.h (local)
@@ -829,7 +829,14 @@ extern ds_t ds_merge (ds_t, ds_t);
extern void debug_ds (ds_t);
/* Functions in haifa-sched.c. */
-extern int haifa_classify_insn (const_rtx);
+extern int haifa_classify_insn_pat (rtx);
+
+static inline int
+haifa_classify_insn (const_rtx insn)
+{
+ return haifa_classify_insn_pat (PATTERN (insn));
+}
+
extern void get_ebb_head_tail (basic_block, basic_block, rtx *, rtx *);
extern int no_real_insns_p (const_rtx, const_rtx);
More information about the Gcc-patches
mailing list