diff options
author | Jakub Jelinek <jakub@redhat.com> | 2017-11-22 10:57:28 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2017-11-22 10:57:28 +0100 |
commit | a2998ed1dc4389e2d648ba376f1eca2c165a2717 (patch) | |
tree | e74efc9fd718473642ee90a0a64c09bac23f4832 /gcc | |
parent | 0a770b5907cdb70709356fbbfe5c570010b0b936 (diff) | |
download | gcc-a2998ed1dc4389e2d648ba376f1eca2c165a2717.zip gcc-a2998ed1dc4389e2d648ba376f1eca2c165a2717.tar.gz gcc-a2998ed1dc4389e2d648ba376f1eca2c165a2717.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/optabs.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr82875.c | 24 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr82875.c | 11 |
5 files changed, 55 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d4b184e..ace7c7c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2017-11-22 Jakub Jelinek <jakub@redhat.com> + 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 847b801..518ce7a 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 b08855f..b7e0c47 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,11 @@ 2017-11-22 Jakub Jelinek <jakub@redhat.com> + PR middle-end/82875 + * gcc.dg/pr82875.c: New test. + * gcc.c-torture/compile/pr82875.c: New test. + +2017-11-22 Jakub Jelinek <jakub@redhat.com> + PR debug/83034 * gcc.dg/pr83034.c: New test. 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 0000000..4360ebc --- /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 0000000..5b97b80 --- /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]; +} |