This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: unroller bug
- To: law at cygnus dot com
- Subject: Re: unroller bug
- From: Michael Hayes <m dot hayes at elec dot canterbury dot ac dot nz>
- Date: Sun, 03 Jan 1999 18:30:58 +1300 (NZDT)
- Cc: Michael Hayes <m dot hayes at elec dot canterbury dot ac dot nz>, egcs-patches at cygnus dot com
- References: <2690.915327701@hurl.cygnus.com>
Jeffrey A Law writes:
> I believe the problem is the unroller is creating non-canonical rtl. In
> particular note from the .loop dump:
>
> (jump_insn 107 105 109 (set (pc)
> (if_then_else (ge (const_int 0)
> (reg/v:SI 96))
> (label_ref 136)
> (pc))) -1 (nil)
> (nil))
This patch ensures that a canonical comparison is generated.
However, it doesn't appear to fix the problem you had :-(
Michael.
Sun Jan 3 18:21:15 1999 Michael Hayes <m.hayes@elec.canterbury.ac.nz>
* unroll.c (unroll_loop): Swap operands and comparison condition
if necessary to ensure that canonical comparison RTL generated.
* optabs.c (emit_cmp_insn): Call abort if first operand is
constant and second operand is not constant.
Index: unroll.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/unroll.c,v
retrieving revision 1.39
diff -c -3 -p -r1.39 unroll.c
*** unroll.c 1998/12/16 20:58:43 1.39
--- unroll.c 1999/01/03 05:17:44
*************** unroll_loop (loop_end, insn_count, loop_
*** 919,930 ****
if (loop_info->comparison_code != NE)
{
! emit_cmp_insn (initial_value, final_value, neg_inc ? LE : GE,
! NULL_RTX, mode, 0, 0);
! if (neg_inc)
! emit_jump_insn (gen_ble (labels[1]));
else
! emit_jump_insn (gen_bge (labels[1]));
JUMP_LABEL (get_last_insn ()) = labels[1];
LABEL_NUSES (labels[1])++;
}
--- 919,944 ----
if (loop_info->comparison_code != NE)
{
! enum rtx_code cmp_code;
! rtx op0, op1;
!
! cmp_code = neg_inc ? LE : GE;
! if (GET_CODE (initial_value) == CONST_INT)
! {
! /* Swap operands and condition to ensure canonical RTL. */
! op0 = final_value;
! op1 = initial_value;
! cmp_code = reverse_condition (cmp_code);
! }
else
! {
! op0 = initial_value;
! op1 = final_value;
! }
! emit_cmp_insn (op0, op1, cmp_code,
! NULL_RTX, mode, 0, 0);
! emit_jump_insn ((*bcc_gen_fctn[(int) cmp_code])
! (labels[1]));
JUMP_LABEL (get_last_insn ()) = labels[1];
LABEL_NUSES (labels[1])++;
}
Index: optabs.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/optabs.c,v
retrieving revision 1.19
diff -c -3 -p -r1.19 optabs.c
*** optabs.c 1998/12/16 20:57:27 1.19
--- optabs.c 1999/01/03 05:17:46
*************** emit_cmp_insn (x, y, comparison, size, m
*** 2722,2727 ****
--- 2722,2731 ----
if (CONSTANT_P (y) && preserve_subexpressions_p () && rtx_cost (y, COMPARE) > 2)
y = force_reg (mode, y);
+ /* Abort if we have a non-canonical comparison. */
+ if (CONSTANT_P (x) && ! CONSTANT_P (y))
+ abort();
+
/* Don't let both operands fail to indicate the mode. */
if (GET_MODE (x) == VOIDmode && GET_MODE (y) == VOIDmode)
x = force_reg (mode, x);