From 6ddae612862ce6cf65cfeddac2d0959d7397d0be Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 25 Mar 2002 12:34:11 +0100 Subject: [PATCH] re PR target/6043 (IICE on ia64 for Blitz config test for C++ complex math) PR target/6043 * expr.c (emit_group_store): Handle storing into CONCAT. * g++.dg/opt/conj2.C: New test. From-SVN: r51311 --- gcc/ChangeLog | 5 +++++ gcc/expr.c | 22 ++++++++++++++++++---- gcc/testsuite/ChangeLog | 2 ++ gcc/testsuite/g++.dg/opt/conj2.C | 23 +++++++++++++++++++++++ 4 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/opt/conj2.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9998544ca26..613342afeb3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2002-03-25 Jakub Jelinek + + PR target/6043 + * expr.c (emit_group_store): Handle storing into CONCAT. + 2002-03-25 Jakub Jelinek * regrename.c (build_def_use): Share RTL between MATCH_OPERATOR and diff --git a/gcc/expr.c b/gcc/expr.c index 3913ebd76a0..e6821d5f28f 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -2113,6 +2113,7 @@ emit_group_store (orig_dst, src, ssize) HOST_WIDE_INT bytepos = INTVAL (XEXP (XVECEXP (src, 0, i), 1)); enum machine_mode mode = GET_MODE (tmps[i]); unsigned int bytelen = GET_MODE_SIZE (mode); + rtx dest = dst; /* Handle trailing fragments that run over the size of the struct. */ if (ssize >= 0 && bytepos + (HOST_WIDE_INT) bytelen > ssize) @@ -2126,14 +2127,27 @@ emit_group_store (orig_dst, src, ssize) bytelen = ssize - bytepos; } + if (GET_CODE (dst) == CONCAT) + { + if (bytepos + bytelen <= GET_MODE_SIZE (GET_MODE (XEXP (dst, 0)))) + dest = XEXP (dst, 0); + else if (bytepos >= GET_MODE_SIZE (GET_MODE (XEXP (dst, 0)))) + { + bytepos -= GET_MODE_SIZE (GET_MODE (XEXP (dst, 0))); + dest = XEXP (dst, 1); + } + else + abort (); + } + /* Optimize the access just a bit. */ - if (GET_CODE (dst) == MEM - && MEM_ALIGN (dst) >= GET_MODE_ALIGNMENT (mode) + if (GET_CODE (dest) == MEM + && MEM_ALIGN (dest) >= GET_MODE_ALIGNMENT (mode) && bytepos * BITS_PER_UNIT % GET_MODE_ALIGNMENT (mode) == 0 && bytelen == GET_MODE_SIZE (mode)) - emit_move_insn (adjust_address (dst, mode, bytepos), tmps[i]); + emit_move_insn (adjust_address (dest, mode, bytepos), tmps[i]); else - store_bit_field (dst, bytelen * BITS_PER_UNIT, bytepos * BITS_PER_UNIT, + store_bit_field (dest, bytelen * BITS_PER_UNIT, bytepos * BITS_PER_UNIT, mode, tmps[i], ssize); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0ec9af500bb..8a22162ec66 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -2,6 +2,8 @@ * gcc.c-torture/compile/20020323-1.c: New test. + * g++.dg/opt/conj2.C: New test. + 2002-03-24 Richard Henderson * gcc.dg/weak-1.c: Use -fno-common. diff --git a/gcc/testsuite/g++.dg/opt/conj2.C b/gcc/testsuite/g++.dg/opt/conj2.C new file mode 100644 index 00000000000..25e832a02c3 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/conj2.C @@ -0,0 +1,23 @@ +// PR target/6043 +// This testcase ICEd on IA-64 because emit_group_store +// did not handle loading CONCAT from register group +// { dg-do compile } + +struct C +{ + C (double y, double z) { __real__ x = y; __imag__ x = z; } + double r () const { return __real__ x; } + double i () const { return __imag__ x; } + __complex__ double x; +}; + +inline C conj (const C& x) +{ + return C (x.r (), - x.i ()); +} + +void foo (void) +{ + C x (1.0, 1.0); + conj (x); +} -- 2.30.2