This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Committed: jump.c fix
- To: gcc-patches at gcc dot gnu dot org
- Subject: Committed: jump.c fix
- From: Bernd Schmidt <bernds at cygnus dot co dot uk>
- Date: Thu, 11 Nov 1999 12:38:05 +0000 (GMT)
I applied the patch below, which was reviewed by Richard Henderson.
The problem was that the following sequence of insns
(insn 324 322 326 (parallel[
(set (reg/v:DI 35) (plus:DI (reg:DI 80) (reg:DI 84)))
(clobber (reg:CC 24 cc))]))
(insn 326 324 327
(set (reg:CC 24 cc) (compare:CC (reg/v:SI 54) (const_int 0 [0x0]))))
(jump_insn 327 326 785
(set (pc) (if_then_else (eq (reg:CC 24 cc) (const_int 0 [0x0]))
(label_ref 732)
(pc))))
(insn 330 785 333 (parallel[
(set (reg/v:DI 35) (neg/v:DI (reg:DI 35)))
(clobber (reg:CC 24 cc))))
matches for an optimization attempt in jump.c:
/* Try to use a conditional move (if the target has them), or a
store-flag insn. If the target has conditional arithmetic as
well as conditional move, the above code will have done something.
Note that we prefer the above code since it is more general: the
code below can make changes that require work to undo.
The general case here is:
1) x = a; if (...) x = b; and ...... */
B is (neg:DI (reg:DI 35)) in this case. The problem is that it gets passed
as operand into expand_and somewhat further below (it has moved to CVAL):
tem2 = expand_and (cval, tem2,
(GET_CODE (tem2) == REG
? tem2 : 0));
Since it's not a valid operand, we get confused.
The patch below avoids the optimization in such a case.
Bernd
* jump.c (jump_optimize_1): Avoid passing an rtx that is not an
operand as argument to expand_and or expand_binop.
Index: jump.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/jump.c,v
retrieving revision 1.164
diff -u -p -r1.164 jump.c
--- jump.c 1999/11/05 09:34:04 1.164
+++ jump.c 1999/11/10 13:05:57
@@ -1582,6 +1582,9 @@ jump_optimize_1 (f, cross_jump, noop_mov
5) if (...) x = b; if jumps are even more expensive. */
if (GET_MODE_CLASS (GET_MODE (temp1)) == MODE_INT
+ /* We will be passing this as operand into expand_and. No
+ good if it's not valid as an operand. */
+ && general_operand (temp2, GET_MODE (temp2))
&& ((GET_CODE (temp3) == CONST_INT)
/* Make the latter case look like
x = x; if (...) x = 0; */