From 76873758402927ca5fca67abc018eab862fd1b96 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 12 Apr 2017 15:57:45 +0200 Subject: [PATCH] re PR middle-end/80163 (ICE on hopefully valid code) PR c/80163 * expr.c : For EXPAND_INITIALIZER determine SIGN_EXTEND vs. ZERO_EXTEND based on signedness of treeop0's type rather than signedness of the result type. * gcc.dg/torture/pr80163.c: New test. From-SVN: r246876 --- gcc/ChangeLog | 11 ++++++-- gcc/expr.c | 3 ++- gcc/testsuite/ChangeLog | 9 +++++-- gcc/testsuite/gcc.dg/torture/pr80163.c | 35 ++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr80163.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1f98b8823af..3a7675e10c2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,12 @@ +2017-04-12 Jakub Jelinek + + PR c/80163 + * expr.c : For EXPAND_INITIALIZER determine SIGN_EXTEND + vs. ZERO_EXTEND based on signedness of treeop0's type rather than + signedness of the result type. + 2017-04-12 Richard Biener - Jeff Law + Jeff Law PR tree-optimization/80359 * tree-ssa-dse.c (maybe_trim_partially_dead_store): Do not @@ -18,7 +25,7 @@ for quad_address_p for TImode, instead of just not indexed_address. 2017-04-12 Richard Biener - Bernd Edlinger + Bernd Edlinger PR middle-end/79671 * alias.c (component_uses_parent_alias_set_from): Handle diff --git a/gcc/expr.c b/gcc/expr.c index 91d7ea21722..29ebad3a061 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -8333,7 +8333,8 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode, } else if (modifier == EXPAND_INITIALIZER) - op0 = gen_rtx_fmt_e (unsignedp ? ZERO_EXTEND : SIGN_EXTEND, mode, op0); + op0 = gen_rtx_fmt_e (TYPE_UNSIGNED (TREE_TYPE (treeop0)) + ? ZERO_EXTEND : SIGN_EXTEND, mode, op0); else if (target == 0) op0 = convert_to_mode (mode, op0, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bc2424a1d6f..f43a4d968a0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,11 +1,16 @@ +2017-04-12 Jakub Jelinek + + PR c/80163 + * gcc.dg/torture/pr80163.c: New test. + 2017-04-12 Richard Biener - Jeff Law + Jeff Law PR tree-optimization/80359 * gcc.dg/torture/pr80359.c: New testcase. 2017-04-12 Richard Biener - Bernd Edlinger + Bernd Edlinger PR middle-end/79671 * g++.dg/torture/pr79671.C: New testcase. diff --git a/gcc/testsuite/gcc.dg/torture/pr80163.c b/gcc/testsuite/gcc.dg/torture/pr80163.c new file mode 100644 index 00000000000..80cc68dd76d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr80163.c @@ -0,0 +1,35 @@ +/* PR c/80163 */ +/* { dg-do compile { target int128 } } */ + +volatile int v; + +__attribute__((noinline, noclone)) void +bar (void) +{ + v++; + asm volatile ("" : : : "memory"); +} + +__attribute__((noinline, noclone)) __int128_t * +foo (unsigned long **p) +{ +a: + bar (); +b: + bar (); + static __int128_t d = (unsigned long) &&a - (unsigned long) &&b; + static unsigned long e = (unsigned long) &&a - (unsigned long) &&b; + *p = &e; + return &d; +} + +int +main () +{ + __int128_t *p; + unsigned long *q; + p = foo (&q); + if (*p != *q) + __builtin_abort (); + return 0; +} -- 2.30.2