|
|
727081 |
2005-01-03 Jakub Jelinek <jakub@redhat.com>
|
|
|
727081 |
|
|
|
727081 |
* cfgrtl.c (try_redirect_by_replacing_jump): Add 2 arguments to
|
|
|
727081 |
tablejump_p.
|
|
|
727081 |
|
|
|
727081 |
* gcc.c-torture/compile/20050103-1.c: New test.
|
|
|
727081 |
|
|
|
727081 |
2003-07-20 Josef Zlomek <zlomekj@suse.cz>
|
|
|
727081 |
|
|
|
727081 |
* cfgcleanup.c (merge_blocks_move_successor_nojumps): Use tablejump_p.
|
|
|
727081 |
* ifcvt.c (find_if_block): Added 2 arguments to tablejump_p.
|
|
|
727081 |
* jump.c (tablejump_p): Added 2 arguments.
|
|
|
727081 |
* rtl.h (tablejump_p): Likewise.
|
|
|
727081 |
|
|
|
727081 |
--- gcc/rtl.h.jj 2003-06-11 14:58:17.000000000 +0200
|
|
|
727081 |
+++ gcc/rtl.h 2005-01-03 17:32:46.113937897 +0100
|
|
|
727081 |
@@ -1793,7 +1793,7 @@ extern rtx pc_set PARAMS ((rtx));
|
|
|
727081 |
extern rtx condjump_label PARAMS ((rtx));
|
|
|
727081 |
extern int simplejump_p PARAMS ((rtx));
|
|
|
727081 |
extern int returnjump_p PARAMS ((rtx));
|
|
|
727081 |
-extern int tablejump_p PARAMS ((rtx));
|
|
|
727081 |
+extern int tablejump_p PARAMS ((rtx, rtx *, rtx *));
|
|
|
727081 |
extern int onlyjump_p PARAMS ((rtx));
|
|
|
727081 |
extern int only_sets_cc0_p PARAMS ((rtx));
|
|
|
727081 |
extern int sets_cc0_p PARAMS ((rtx));
|
|
|
727081 |
--- gcc/cfgrtl.c.jj 2003-04-08 15:50:58.000000000 +0200
|
|
|
727081 |
+++ gcc/cfgrtl.c 2005-01-03 17:37:59.150837447 +0100
|
|
|
727081 |
@@ -674,7 +674,7 @@ try_redirect_by_replacing_jump (e, targe
|
|
|
727081 |
if (tmp || !onlyjump_p (insn))
|
|
|
727081 |
return false;
|
|
|
727081 |
|
|
|
727081 |
- if ((!optimize || flow2_completed) && tablejump_p (insn))
|
|
|
727081 |
+ if ((!optimize || flow2_completed) && tablejump_p (insn, NULL, NULL))
|
|
|
727081 |
return false;
|
|
|
727081 |
|
|
|
727081 |
/* Avoid removing branch with side effects. */
|
|
|
727081 |
--- gcc/cfgcleanup.c.jj 2003-08-02 01:18:22.000000000 +0200
|
|
|
727081 |
+++ gcc/cfgcleanup.c 2005-01-03 17:32:10.010407336 +0100
|
|
|
727081 |
@@ -691,25 +691,20 @@ merge_blocks_move_successor_nojumps (a,
|
|
|
727081 |
basic_block a, b;
|
|
|
727081 |
{
|
|
|
727081 |
rtx barrier, real_b_end;
|
|
|
727081 |
+ rtx label, table;
|
|
|
727081 |
|
|
|
727081 |
real_b_end = b->end;
|
|
|
727081 |
- barrier = NEXT_INSN (b->end);
|
|
|
727081 |
|
|
|
727081 |
- /* Recognize a jump table following block B. */
|
|
|
727081 |
- if (barrier
|
|
|
727081 |
- && GET_CODE (barrier) == CODE_LABEL
|
|
|
727081 |
- && NEXT_INSN (barrier)
|
|
|
727081 |
- && GET_CODE (NEXT_INSN (barrier)) == JUMP_INSN
|
|
|
727081 |
- && (GET_CODE (PATTERN (NEXT_INSN (barrier))) == ADDR_VEC
|
|
|
727081 |
- || GET_CODE (PATTERN (NEXT_INSN (barrier))) == ADDR_DIFF_VEC))
|
|
|
727081 |
+ /* If there is a jump table following block B temporarily add the jump table
|
|
|
727081 |
+ to block B so that it will also be moved to the correct location. */
|
|
|
727081 |
+ if (tablejump_p (b->end, &label, &table)
|
|
|
727081 |
+ && prev_active_insn (label) == b->end)
|
|
|
727081 |
{
|
|
|
727081 |
- /* Temporarily add the table jump insn to b, so that it will also
|
|
|
727081 |
- be moved to the correct location. */
|
|
|
727081 |
- b->end = NEXT_INSN (barrier);
|
|
|
727081 |
- barrier = NEXT_INSN (b->end);
|
|
|
727081 |
+ b->end = table;
|
|
|
727081 |
}
|
|
|
727081 |
|
|
|
727081 |
/* There had better have been a barrier there. Delete it. */
|
|
|
727081 |
+ barrier = NEXT_INSN (b->end);
|
|
|
727081 |
if (barrier && GET_CODE (barrier) == BARRIER)
|
|
|
727081 |
delete_insn (barrier);
|
|
|
727081 |
|
|
|
727081 |
--- gcc/jump.c.jj 2003-08-01 22:38:45.000000000 +0200
|
|
|
727081 |
+++ gcc/jump.c 2005-01-03 17:36:59.744484787 +0100
|
|
|
727081 |
@@ -1099,20 +1099,32 @@ simplejump_p (insn)
|
|
|
727081 |
&& GET_CODE (SET_DEST (PATTERN (insn))) == PC
|
|
|
727081 |
&& GET_CODE (SET_SRC (PATTERN (insn))) == LABEL_REF);
|
|
|
727081 |
}
|
|
|
727081 |
-/* Return 1 if INSN is an tablejump. */
|
|
|
727081 |
+
|
|
|
727081 |
+/* If INSN is a tablejump return 1 and store the label (before jump table) to
|
|
|
727081 |
+ *LABELP and the jump table to *TABLEP. LABELP and TABLEP may be NULL. */
|
|
|
727081 |
|
|
|
727081 |
int
|
|
|
727081 |
-tablejump_p (insn)
|
|
|
727081 |
+tablejump_p (insn, labelp, tablep)
|
|
|
727081 |
rtx insn;
|
|
|
727081 |
+ rtx *labelp;
|
|
|
727081 |
+ rtx *tablep;
|
|
|
727081 |
{
|
|
|
727081 |
- rtx table;
|
|
|
727081 |
- return (GET_CODE (insn) == JUMP_INSN
|
|
|
727081 |
- && JUMP_LABEL (insn)
|
|
|
727081 |
- && NEXT_INSN (JUMP_LABEL (insn))
|
|
|
727081 |
- && (table = next_active_insn (JUMP_LABEL (insn)))
|
|
|
727081 |
- && GET_CODE (table) == JUMP_INSN
|
|
|
727081 |
- && (GET_CODE (PATTERN (table)) == ADDR_VEC
|
|
|
727081 |
- || GET_CODE (PATTERN (table)) == ADDR_DIFF_VEC));
|
|
|
727081 |
+ rtx label, table;
|
|
|
727081 |
+
|
|
|
727081 |
+ if (GET_CODE (insn) == JUMP_INSN
|
|
|
727081 |
+ && (label = JUMP_LABEL (insn)) != NULL_RTX
|
|
|
727081 |
+ && (table = next_active_insn (label)) != NULL_RTX
|
|
|
727081 |
+ && GET_CODE (table) == JUMP_INSN
|
|
|
727081 |
+ && (GET_CODE (PATTERN (table)) == ADDR_VEC
|
|
|
727081 |
+ || GET_CODE (PATTERN (table)) == ADDR_DIFF_VEC))
|
|
|
727081 |
+ {
|
|
|
727081 |
+ if (labelp)
|
|
|
727081 |
+ *labelp = label;
|
|
|
727081 |
+ if (tablep)
|
|
|
727081 |
+ *tablep = table;
|
|
|
727081 |
+ return 1;
|
|
|
727081 |
+ }
|
|
|
727081 |
+ return 0;
|
|
|
727081 |
}
|
|
|
727081 |
|
|
|
727081 |
/* Return nonzero if INSN is a (possibly) conditional jump
|
|
|
727081 |
--- gcc/ifcvt.c.jj 2003-03-25 17:42:24.000000000 +0100
|
|
|
727081 |
+++ gcc/ifcvt.c 2005-01-03 17:32:10.012406978 +0100
|
|
|
727081 |
@@ -2046,7 +2046,7 @@ find_if_block (test_bb, then_edge, else_
|
|
|
727081 |
if (then_succ != NULL_EDGE
|
|
|
727081 |
&& (then_succ->succ_next != NULL_EDGE
|
|
|
727081 |
|| (then_succ->flags & EDGE_COMPLEX)
|
|
|
727081 |
- || (flow2_completed && tablejump_p (then_bb->end))))
|
|
|
727081 |
+ || (flow2_completed && tablejump_p (then_bb->end, NULL, NULL))))
|
|
|
727081 |
return FALSE;
|
|
|
727081 |
|
|
|
727081 |
/* If the THEN block has no successors, conditional execution can still
|
|
|
727081 |
@@ -2094,7 +2094,7 @@ find_if_block (test_bb, then_edge, else_
|
|
|
727081 |
&& else_bb->pred->pred_next == NULL_EDGE
|
|
|
727081 |
&& else_succ->succ_next == NULL_EDGE
|
|
|
727081 |
&& ! (else_succ->flags & EDGE_COMPLEX)
|
|
|
727081 |
- && ! (flow2_completed && tablejump_p (else_bb->end)))
|
|
|
727081 |
+ && ! (flow2_completed && tablejump_p (else_bb->end, NULL, NULL)))
|
|
|
727081 |
join_bb = else_succ->dest;
|
|
|
727081 |
|
|
|
727081 |
/* Otherwise it is not an IF-THEN or IF-THEN-ELSE combination. */
|
|
|
727081 |
--- gcc/testsuite/gcc.c-torture/compile/20050103-1.c.jj 2004-12-09 13:34:01.422415552 +0100
|
|
|
727081 |
+++ gcc/testsuite/gcc.c-torture/compile/20050103-1.c 2005-01-03 15:21:18.146431991 +0100
|
|
|
727081 |
@@ -0,0 +1,83 @@
|
|
|
727081 |
+extern void abort (void);
|
|
|
727081 |
+
|
|
|
727081 |
+struct S
|
|
|
727081 |
+{
|
|
|
727081 |
+ char *s1;
|
|
|
727081 |
+ int s2;
|
|
|
727081 |
+};
|
|
|
727081 |
+struct T
|
|
|
727081 |
+{
|
|
|
727081 |
+ int t1;
|
|
|
727081 |
+ struct S *t2;
|
|
|
727081 |
+} *s1;
|
|
|
727081 |
+
|
|
|
727081 |
+extern int bar (const struct T *, unsigned int, unsigned int,
|
|
|
727081 |
+ const struct T *, unsigned int, unsigned int);
|
|
|
727081 |
+
|
|
|
727081 |
+extern inline void *
|
|
|
727081 |
+baz (void *x, const void *y, unsigned int z)
|
|
|
727081 |
+{
|
|
|
727081 |
+ unsigned char *s1 = x;
|
|
|
727081 |
+ const unsigned char *s2 = y;
|
|
|
727081 |
+
|
|
|
727081 |
+ if (z > 4 || __builtin_constant_p (z))
|
|
|
727081 |
+ __builtin_memcpy (x, y, z);
|
|
|
727081 |
+ else
|
|
|
727081 |
+ switch (z)
|
|
|
727081 |
+ {
|
|
|
727081 |
+ case 4:
|
|
|
727081 |
+ s1[3] = s2[3];
|
|
|
727081 |
+ case 3:
|
|
|
727081 |
+ s1[2] = s2[2];
|
|
|
727081 |
+ case 2:
|
|
|
727081 |
+ s1[1] = s2[1];
|
|
|
727081 |
+ case 1:
|
|
|
727081 |
+ s1[0] = s2[0];
|
|
|
727081 |
+ case 0:
|
|
|
727081 |
+ break;
|
|
|
727081 |
+ }
|
|
|
727081 |
+
|
|
|
727081 |
+ return x;
|
|
|
727081 |
+}
|
|
|
727081 |
+
|
|
|
727081 |
+extern inline int
|
|
|
727081 |
+foo (struct T *b, unsigned int x, const void *y, unsigned int z)
|
|
|
727081 |
+{
|
|
|
727081 |
+ if (!b || !z)
|
|
|
727081 |
+ return 0;
|
|
|
727081 |
+ if (x == b->t1)
|
|
|
727081 |
+ {
|
|
|
727081 |
+ struct S *r = b->t2;
|
|
|
727081 |
+ baz (r->s1 + r->s2, y, z);
|
|
|
727081 |
+ return 1;
|
|
|
727081 |
+ }
|
|
|
727081 |
+
|
|
|
727081 |
+ return 0;
|
|
|
727081 |
+}
|
|
|
727081 |
+
|
|
|
727081 |
+int
|
|
|
727081 |
+test (struct T *a, struct T *b, struct T *c, struct T *d)
|
|
|
727081 |
+{
|
|
|
727081 |
+ if (!a)
|
|
|
727081 |
+ abort ();
|
|
|
727081 |
+ if (!b)
|
|
|
727081 |
+ abort ();
|
|
|
727081 |
+
|
|
|
727081 |
+ if (bar (a, 1, a->t1, b, 1, b->t1) > 0)
|
|
|
727081 |
+ abort ();
|
|
|
727081 |
+ if (bar (a, 41, a->t1 - 40, b, 1, b->t1) > 0)
|
|
|
727081 |
+ abort ();
|
|
|
727081 |
+
|
|
|
727081 |
+ if (!c)
|
|
|
727081 |
+ abort ();
|
|
|
727081 |
+ if (!d)
|
|
|
727081 |
+ abort ();
|
|
|
727081 |
+
|
|
|
727081 |
+ if (bar (c, 1, c->t1, d, 1, d->t1) < 0)
|
|
|
727081 |
+ abort ();
|
|
|
727081 |
+ if (bar (c, 41, c->t1 - 40, d, 1, d->t1) < 0)
|
|
|
727081 |
+ abort ();
|
|
|
727081 |
+
|
|
|
727081 |
+ foo (s1, 0, "abcd", 4);
|
|
|
727081 |
+ return 0;
|
|
|
727081 |
+}
|