From: Richard Henderson Date: Thu, 24 Oct 2002 08:59:50 +0000 (-0700) Subject: re PR rtl-optimization/7944 (gcc 3.2: Internal compiler error in find_reloads_toplev... X-Git-Tag: releases/gcc-3.2.1~108 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a3cea2b6cc11efacec89cbfc1c569079a1f88b6;p=thirdparty%2Fgcc.git re PR rtl-optimization/7944 (gcc 3.2: Internal compiler error in find_reloads_toplev, at reload.c:4462) PR opt/7944 * reload.c (find_reloads_toplev): Use simplify_gen_subreg; mode of X is not important when simplifying subregs of constants. * g++.dg/opt/reload1.C: New. From-SVN: r58489 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6a03ecd48500..c30bd15baec1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2002-10-24 Richard Henderson + + PR opt/7944 + * reload.c (find_reloads_toplev): Use simplify_gen_subreg; mode + of X is not important when simplifying subregs of constants. + 2002-10-23 Robert Lipe * config.gcc (i[34567]86-*-sco3.2v5*): Fix tm_file. diff --git a/gcc/reload.c b/gcc/reload.c index 166e11066205..71ed1d6771c3 100644 --- a/gcc/reload.c +++ b/gcc/reload.c @@ -4427,20 +4427,12 @@ find_reloads_toplev (x, opnum, type, ind_levels, is_set_dest, insn, reg_equiv_constant[regno])) != 0) return tem; - if (GET_MODE_BITSIZE (GET_MODE (x)) == BITS_PER_WORD - && regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] < 0 - && reg_equiv_constant[regno] != 0 - && (tem = operand_subword (reg_equiv_constant[regno], - SUBREG_BYTE (x) / UNITS_PER_WORD, 0, - GET_MODE (SUBREG_REG (x)))) != 0) + if (regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] < 0 + && reg_equiv_constant[regno] != 0) { - /* TEM is now a word sized constant for the bits from X that - we wanted. However, TEM may be the wrong representation. - - Use gen_lowpart_common to convert a CONST_INT into a - CONST_DOUBLE and vice versa as needed according to by the mode - of the SUBREG. */ - tem = gen_lowpart_common (GET_MODE (x), tem); + tem = + simplify_gen_subreg (GET_MODE (x), reg_equiv_constant[regno], + GET_MODE (SUBREG_REG (x)), SUBREG_BYTE (x)); if (!tem) abort (); return tem; diff --git a/gcc/testsuite/g++.dg/opt/reload1.C b/gcc/testsuite/g++.dg/opt/reload1.C new file mode 100644 index 000000000000..0d8fb894e4e1 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/reload1.C @@ -0,0 +1,43 @@ +// PR 7944 +// { dg-do compile } +// { dg-options -O2 } + +struct B +{ + B & operator << (short s) + { + int j; + if (j) + return operator << (s); + else + return operator << (s); + } +}; + +struct A +{ + int i; + static void bar (); + static int quux () + { + bar (); + return 0; + } + + A ():i (quux ()) + { + } + ~A () + { + } +}; + +void +foo () +{ + short s[4] = { 0, 0, 0, 1 }; + A a[2] = { A (), A () }; + + B b; + b << s[0] << s[2]; +}