This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Use reversed_comparison_code in sched-deps.c
- From: Richard Earnshaw <rearnsha at buzzard dot freeserve dot co dot uk>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Richard dot Earnshaw at buzzard dot freeserve dot co dot uk
- Date: Sun, 29 Aug 2004 22:16:34 +0100
- Subject: [PATCH] Use reversed_comparison_code in sched-deps.c
- Reply-to: Richard dot Earnshaw at buzzard dot freeserve dot co dot uk
Sched-deps.c has to handle comparison operations that might involve
floating point operands. It's therefore undesirable for this to be using
reverse_condition, since that just returns UNKNOWN in some circumstances
and the incorrect (integer) reversal in others. This patch fixes both
instances where this can happen by using reversed_comparison_code, which
does know how to do the right thing (in one case we don't have an insn to
pass, but that shouldn't affect correctness, just whether or not we can do
an optimization, and even then only on ports that don't define
REVERSE_CONDITION).
Secondly this patch fixes what must have been a long-standing bug in
get_condition (the version in this file, not the identically named one in
the loop optimizer), where we looked in the SET_DEST of a jump for an
IF_THEN_ELSE when we should have been looking in the SET_SRC. In fixing
this I've made use of the various support functions in jump.c to make the
code more general.
Tested on i386-netbsdelf2 and arm-linux-gnu with no regressions.
2004-08-29 Richard Earnshaw <rearnsha@arm.com>
* sched-deps.c (get_condition): Rewrite using jump support functions.
Use reversed_comparison_code.
(conditions_mutex_p): Use reversed_comparison_code.
Index: sched-deps.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/sched-deps.c,v
retrieving revision 1.76
diff -p -p -r1.76 sched-deps.c
*** sched-deps.c 9 Jul 2004 03:29:35 -0000 1.76
--- sched-deps.c 29 Aug 2004 20:30:03 -0000
*************** get_condition (rtx insn)
*** 145,167 ****
if (pat == 0)
return 0;
if (GET_CODE (pat) == COND_EXEC)
return COND_EXEC_TEST (pat);
! if (!JUMP_P (insn))
! return 0;
! if (GET_CODE (pat) != SET || SET_SRC (pat) != pc_rtx)
! return 0;
! if (GET_CODE (SET_DEST (pat)) != IF_THEN_ELSE)
return 0;
! pat = SET_DEST (pat);
! cond = XEXP (pat, 0);
! if (GET_CODE (XEXP (cond, 1)) == LABEL_REF
! && XEXP (cond, 2) == pc_rtx)
return cond;
! else if (GET_CODE (XEXP (cond, 2)) == LABEL_REF
! && XEXP (cond, 1) == pc_rtx)
! return gen_rtx_fmt_ee (reverse_condition (GET_CODE (cond)), GET_MODE (cond),
! XEXP (cond, 0), XEXP (cond, 1));
else
return 0;
}
--- 145,169 ----
if (pat == 0)
return 0;
+
if (GET_CODE (pat) == COND_EXEC)
return COND_EXEC_TEST (pat);
!
! if (!any_condjump_p (insn) || !onlyjump_p (insn))
return 0;
!
! cond = XEXP (SET_SRC (pc_set (insn)), 0);
! if (XEXP (cond, 2) == pc_rtx)
return cond;
! else if (XEXP (cond, 1) == pc_rtx)
! {
! enum rtx_code revcode = reversed_comparison_code (cond, insn);
!
! if (revcode == UNKNOWN)
! return 0;
! return gen_rtx_fmt_ee (revcode, GET_MODE (cond), XEXP (cond, 0),
! XEXP (cond, 1));
! }
else
return 0;
}
*************** conditions_mutex_p (rtx cond1, rtx cond2
*** 173,179 ****
{
if (COMPARISON_P (cond1)
&& COMPARISON_P (cond2)
! && GET_CODE (cond1) == reverse_condition (GET_CODE (cond2))
&& XEXP (cond1, 0) == XEXP (cond2, 0)
&& XEXP (cond1, 1) == XEXP (cond2, 1))
return 1;
--- 175,181 ----
{
if (COMPARISON_P (cond1)
&& COMPARISON_P (cond2)
! && GET_CODE (cond1) == reversed_comparison_code (cond2, NULL)
&& XEXP (cond1, 0) == XEXP (cond2, 0)
&& XEXP (cond1, 1) == XEXP (cond2, 1))
return 1;