From: Jakub Jelinek Date: Wed, 22 Nov 2017 09:57:28 +0000 (+0100) Subject: re PR middle-end/82875 (ICE at -Os on valid code on x86_64-linux-gnu: in find_widenin... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a2998ed1dc4389e2d648ba376f1eca2c165a2717;p=gcc.git re PR middle-end/82875 (ICE at -Os on valid code on x86_64-linux-gnu: in find_widening_optab_handler_and_mode, at optabs-query.c:414) PR middle-end/82875 * optabs.c (expand_doubleword_mult, expand_binop): Before calling expand_binop with *mul_widen_optab, make sure at least one of the operands doesn't have VOIDmode. * gcc.dg/pr82875.c: New test. * gcc.c-torture/compile/pr82875.c: New test. From-SVN: r255050 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d4b184e1262..ace7c7c0ce7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2017-11-22 Jakub Jelinek + PR middle-end/82875 + * optabs.c (expand_doubleword_mult, expand_binop): Before calling + expand_binop with *mul_widen_optab, make sure at least one of the + operands doesn't have VOIDmode. + PR debug/83034 * dwarf2out.c (mem_loc_descriptor): Handle VEC_SERIES. diff --git a/gcc/optabs.c b/gcc/optabs.c index 847b801d288..518ce7a972c 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -861,6 +861,11 @@ expand_doubleword_mult (machine_mode mode, rtx op0, rtx op1, rtx target, if (target && !REG_P (target)) target = NULL_RTX; + /* *_widen_optab needs to determine operand mode, make sure at least + one operand has non-VOID mode. */ + if (GET_MODE (op0_low) == VOIDmode && GET_MODE (op1_low) == VOIDmode) + op0_low = force_reg (word_mode, op0_low); + if (umulp) product = expand_binop (mode, umul_widen_optab, op0_low, op1_low, target, 1, OPTAB_DIRECT); @@ -1199,6 +1204,10 @@ expand_binop (machine_mode mode, optab binoptab, rtx op0, rtx op1, : smul_widen_optab), wider_mode, mode) != CODE_FOR_nothing)) { + /* *_widen_optab needs to determine operand mode, make sure at least + one operand has non-VOID mode. */ + if (GET_MODE (op0) == VOIDmode && GET_MODE (op1) == VOIDmode) + op0 = force_reg (mode, op0); temp = expand_binop (wider_mode, unsignedp ? umul_widen_optab : smul_widen_optab, op0, op1, NULL_RTX, unsignedp, OPTAB_DIRECT); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b08855f9566..b7e0c470c4c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2017-11-22 Jakub Jelinek + + PR middle-end/82875 + * gcc.dg/pr82875.c: New test. + * gcc.c-torture/compile/pr82875.c: New test. + 2017-11-22 Jakub Jelinek PR debug/83034 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr82875.c b/gcc/testsuite/gcc.c-torture/compile/pr82875.c new file mode 100644 index 00000000000..4360ebcfe78 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr82875.c @@ -0,0 +1,24 @@ +/* PR middle-end/82875 */ + +signed char a; +unsigned b; +long c, d; +long long e; + +void +foo (void) +{ + short f = a = 6; + while (0) + while (a <= 7) + { + for (;;) + ; + lab: + while (c <= 73) + ; + e = 20; + d ? (a %= c) * (e *= a ? f : b) : 0; + } + goto lab; +} diff --git a/gcc/testsuite/gcc.dg/pr82875.c b/gcc/testsuite/gcc.dg/pr82875.c new file mode 100644 index 00000000000..5b97b80da26 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr82875.c @@ -0,0 +1,11 @@ +/* PR middle-end/82875 */ +/* { dg-do compile } */ +/* { dg-options "-ftree-ter" } */ + +const int a = 100; + +void +foo (void) +{ + int c[a]; +}