re PR middle-end/80163 (ICE on hopefully valid code)
authorJakub Jelinek <jakub@gcc.gnu.org>
Wed, 12 Apr 2017 13:57:45 +0000 (15:57 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 12 Apr 2017 13:57:45 +0000 (15:57 +0200)
PR c/80163
* expr.c <CASE_CONVERT>: 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
gcc/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr80163.c [new file with mode: 0644]

index 1f98b8823af0eaedab26d5e93e1e241d8aa5fff1..3a7675e10c2c836946518b99cdfc32e2602ae2dc 100644 (file)
@@ -1,5 +1,12 @@
+2017-04-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/80163
+       * expr.c <CASE_CONVERT>: 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  <rguenther@suse.de>
-       Jeff Law  <law@redhat.com>
+           Jeff Law  <law@redhat.com>
 
        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  <rguenther@suse.de>
-       Bernd Edlinger  <bernd.edlinger@hotmail.de>
+           Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
        PR middle-end/79671
        * alias.c (component_uses_parent_alias_set_from): Handle
index 91d7ea217229fac62380b5d4b646961bf7c836c1..29ebad3a061f6545fbfa5dd404072a6a3bcae42b 100644 (file)
@@ -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,
index bc2424a1d6fc0e0a901fe22dce11ee0d7b1b858a..f43a4d968a0a842fa7d1079739d281e3d10afb7f 100644 (file)
@@ -1,11 +1,16 @@
+2017-04-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/80163
+       * gcc.dg/torture/pr80163.c: New test.
+
 2017-04-12  Richard Biener  <rguenther@suse.de>
-       Jeff Law  <law@redhat.com>
+           Jeff Law  <law@redhat.com>
 
        PR tree-optimization/80359
        * gcc.dg/torture/pr80359.c: New testcase.
 
 2017-04-12  Richard Biener  <rguenther@suse.de>
-       Bernd Edlinger  <bernd.edlinger@hotmail.de>
+           Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
        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 (file)
index 0000000..80cc68d
--- /dev/null
@@ -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;
+}