This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] regmove.c: Fix an ICE.
- To: gcc-patches at gcc dot gnu dot org
- Subject: [patch] regmove.c: Fix an ICE.
- From: Kazu Hirata <kazu at hxi dot com>
Hi,
Attached is a patch to prevent replacement of a reg with another reg
of a different mode in regmove_optimize.
When building a cross compiler for h8300-hms, the build process stops
with an ICE while compiling a function in libgcc2.c. Simplified down
to the bare minimum, the following code causes the same ICE.
/* cc1 -mh -O2 -o kazu.s kazu.o */
unsigned short
mul (unsigned short u, unsigned short v)
{
return u * v;
}
The error message goes like
kazu.c: In function `mul':
kazu.c:5: Internal compiler error in simplify_subreg, at simplify-rtx.c:2249
Without the patch, arguments to fixup_match_1 look like
backward: 0
insn:
(insn 43 42 45 (set (reg:SI 35)
(mult:SI (zero_extend:SI (reg/v:HI 26))
(zero_extend:SI (reg/v:HI 29)))) 36 {umulhisi3} (insn_list 37 (nil))
(expr_list:REG_DEAD (reg/v:HI 26)
(nil)))
set: (set (reg:SI 35)
(mult:SI (zero_extend:SI (reg/v:HI 26))
(zero_extend:SI (reg/v:HI 29))))
src: (reg/v:HI 26)
src_subreg: (reg/v:HI 26)
dst: (reg:SI 35)
simplify_subreg seems to get mad when it sees inner and outer mode of
subreg expression have the same size.
I am not confident about the patch because I am not familiar with
regmove.c, but I hope this will be a starting point.
Thanks,
Kazu Hirata
2001-07-23 Kazu Hirata <kazu@hxi.com>
* regmove.c (regmove_optimize): Don't replace a reg with
another reg of a different mode.
Index: regmove.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/regmove.c,v
retrieving revision 1.108
diff -u -p -r1.108 regmove.c
--- regmove.c 2001/07/10 10:38:05 1.108
+++ regmove.c 2001/07/24 00:52:36
@@ -1244,6 +1244,9 @@ regmove_optimize (f, nregs, regmove_dump
if (! regclass_compatible_p (src_class, dst_class))
continue;
+ if (GET_MODE (src) != GET_MODE (dst))
+ continue;
+
if (fixup_match_1 (insn, set, src, src_subreg, dst, pass,
op_no, match_no,
regmove_dump_file))