From: Jeff Law Date: Fri, 28 Mar 2014 22:02:32 +0000 (-0600) Subject: re PR target/60648 (ICE (segmentation fault) in expand_binop) X-Git-Tag: releases/gcc-4.9.0~239 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7f317893469434eeb833e29fa888ee33a488f3e;p=thirdparty%2Fgcc.git re PR target/60648 (ICE (segmentation fault) in expand_binop) PR target/60648 * expr.c (do_tablejump): Use simplify_gen_binary rather than gen_rtx_{PLUS,MULT} to build up the address expression. * i386/i386.c (ix86_legitimize_address): Use copy_addr_to_reg to avoid creating non-canonical RTL. PR target/60648 * g++.dg/pr60648.C: New test. Co-Authored-By: Jakub Jelinek From-SVN: r208924 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a4108ad12782..f3899b7cb114 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2014-03-27 Jeff Law + Jakub Jalinek + + PR target/60648 + * expr.c (do_tablejump): Use simplify_gen_binary rather than + gen_rtx_{PLUS,MULT} to build up the address expression. + + * i386/i386.c (ix86_legitimize_address): Use copy_addr_to_reg to avoid + creating non-canonical RTL. + 2014-03-28 Jan Hubicka PR ipa/60243 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 328fe409bacc..3eefe4ac5983 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -13925,13 +13925,13 @@ ix86_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED, if (GET_CODE (XEXP (x, 0)) == MULT) { changed = 1; - XEXP (x, 0) = force_operand (XEXP (x, 0), 0); + XEXP (x, 0) = copy_addr_to_reg (XEXP (x, 0)); } if (GET_CODE (XEXP (x, 1)) == MULT) { changed = 1; - XEXP (x, 1) = force_operand (XEXP (x, 1), 0); + XEXP (x, 1) = copy_addr_to_reg (XEXP (x, 1)); } if (changed diff --git a/gcc/expr.c b/gcc/expr.c index cdb45518d275..ebf136ed5a30 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -11134,11 +11134,12 @@ do_tablejump (rtx index, enum machine_mode mode, rtx range, rtx table_label, GET_MODE_SIZE, because this indicates how large insns are. The other uses should all be Pmode, because they are addresses. This code could fail if addresses and insns are not the same size. */ - index = gen_rtx_PLUS - (Pmode, - gen_rtx_MULT (Pmode, index, - gen_int_mode (GET_MODE_SIZE (CASE_VECTOR_MODE), Pmode)), - gen_rtx_LABEL_REF (Pmode, table_label)); + index = simplify_gen_binary (MULT, Pmode, index, + gen_int_mode (GET_MODE_SIZE (CASE_VECTOR_MODE), + Pmode)); + index = simplify_gen_binary (PLUS, Pmode, index, + gen_rtx_LABEL_REF (Pmode, table_label)); + #ifdef PIC_CASE_VECTOR_ADDRESS if (flag_pic) index = PIC_CASE_VECTOR_ADDRESS (index); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5d9b43358f70..7601833bd117 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-03-27 Jeff Law + + PR target/60648 + * g++.dg/pr60648.C: New test. + 2014-03-28 Adam Butcher PR c++/60573 diff --git a/gcc/testsuite/g++.dg/pr60648.C b/gcc/testsuite/g++.dg/pr60648.C new file mode 100644 index 000000000000..80c05616c2fd --- /dev/null +++ b/gcc/testsuite/g++.dg/pr60648.C @@ -0,0 +1,73 @@ +/* { dg-do compile } */ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O3 -fPIC -m32" } */ + +enum component +{ + Ex, + Ez, + Hy, + Permeability +}; +enum derived_component +{}; +enum direction +{ + X, + Y, + Z, + R, + P, + NO_DIRECTION +}; +derived_component a; +component *b; +component c; +direction d; +inline direction fn1 (component p1) +{ + switch (p1) + { + case 0: + return Y; + case 1: + return Z; + case Permeability: + return NO_DIRECTION; + } + return X; +} + +inline component fn2 (direction p1) +{ + switch (p1) + { + case 0: + case 1: + return component (); + case Z: + case R: + return component (1); + case P: + return component (3); + } +} + +void fn3 () +{ + direction e; + switch (0) + case 0: + switch (a) + { + case 0: + c = Ex; + b[1] = Hy; + } + e = fn1 (b[1]); + b[1] = fn2 (e); + d = fn1 (c); +} + + +