This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch to prevent do_tablejump from marking vector as unchanging
- To: gcc-patches at gcc dot gnu dot org
- Subject: Patch to prevent do_tablejump from marking vector as unchanging
- From: John Wehle <john at feith dot com>
- Date: Wed, 16 Aug 2000 03:22:57 -0400 (EDT)
The documentation in rtl.h for unchanging says:
1 in a MEM or REG if value of this expression will never change
during the current function, even though it is not
manifestly constant.
Compiling:
void
func (int a)
{
int i;
for (i = 0; i < a; i++)
switch (i)
{
case 0: subr0(); break;
case 1: subr1(); break;
case 2: subr2(); break;
case 3: subr3(); break;
case 4: subr4(); break;
default: break;
}
}
for x86 results in:
(insn 58 56 60 (set (reg:SI 44)
(label_ref:SI 63)) -1 (nil)
(expr_list:REG_EQUAL (label_ref:SI 63)
(nil)))
(insn 60 58 61 (set (reg:SI 45)
(mem/u:SI (plus:SI (mult:SI (reg/v:SI 43)
(const_int 4 [0x4]))
(reg:SI 44)) 0)) -1 (nil)
(nil))
The MEM in INSN 60 is incorrectly marked as unchanging (it depends on REG 43
which is the loop counter). This patch passes make bootstrap and make check
on Compaq Tru64 UNIX 4.0f and FreeBSD-3.5 x86.
ChangeLog:
Tue Aug 15 02:57:58 EDT 2000 John Wehle (john@feith.com)
* expr.c (do_tablejump): Don't mark vector as unchanging.
Enjoy!
-- John Wehle
------------------8<------------------------8<------------------------
*** gcc/expr.c.ORIGINAL Mon Jul 31 02:37:52 2000
--- gcc/expr.c Tue Aug 15 02:55:38 2000
*************** do_tablejump (index, mode, range, table_
*** 10468,10474 ****
index = memory_address_noforce (CASE_VECTOR_MODE, index);
temp = gen_reg_rtx (CASE_VECTOR_MODE);
vector = gen_rtx_MEM (CASE_VECTOR_MODE, index);
- RTX_UNCHANGING_P (vector) = 1;
convert_move (temp, vector, 0);
emit_jump_insn (gen_tablejump (temp, table_label));
--- 10468,10473 ----
-------------------------------------------------------------------------
| Feith Systems | Voice: 1-215-646-8000 | Email: john@feith.com |
| John Wehle | Fax: 1-215-540-5495 | |
-------------------------------------------------------------------------