From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 122436 invoked by alias); 28 Oct 2016 08:52:50 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 122424 invoked by uid 89); 28 Oct 2016 08:52:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 28 Oct 2016 08:52:39 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D9135AAC7; Fri, 28 Oct 2016 08:52:34 +0000 (UTC) Date: Fri, 28 Oct 2016 08:52:00 -0000 From: Richard Biener To: Jakub Jelinek cc: Jeff Law , Eric Botcazou , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Fix COMPONENT_REF expansion (PR rtl-optimization/77919) In-Reply-To: <20161028084604.GT3541@tucnak.redhat.com> Message-ID: References: <20161027193422.GR3541@tucnak.redhat.com> <4f9cb9d7-4075-dcbc-beab-8a78d23e758e@redhat.com> <20161028084604.GT3541@tucnak.redhat.com> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2016-10/txt/msg02323.txt.bz2 On Fri, 28 Oct 2016, Jakub Jelinek wrote: > On Fri, Oct 28, 2016 at 01:32:22AM -0600, Jeff Law wrote: > > >I think so. I'll leave the rest to people more familiar with RTL > > >expansion -- generally I thought the callers of expand() have to deal > > >with expansions that return a different mode? > > You generally have to deal with expansions that return the object in a new > > pseudo instead of the one you asked for -- so the caller has to test for > > that and emit a copy when it happens. > > > > I don't offhand recall cases where we have to deal with getting a result in > > a different mode than was asked. But given the history of the expanders, I > > wouldn't be surprised if there's oddball cases where that can happen. > > I've already committed the original patch based on Eric's review, but > managed to come up with another testcase that still ICEs (one with two > different complex modes). Is the following ok for trunk if it passes > bootstrap/regtest? As we're dealing with memory isn't GET_MODE_SIZE the correct thing to use? > 2016-10-28 Jakub Jelinek > > PR rtl-optimization/77919 > * expr.c (expand_expr_real_1) : Only avoid forcing > into memory if both modes are complex and their inner modes have the > same precision. If the two modes are different complex modes, convert > each part separately and generate a new CONCAT. > > * g++.dg/torture/pr77919-2.C: New test. > > --- gcc/expr.c.jj 2016-10-28 10:35:14.753234774 +0200 > +++ gcc/expr.c 2016-10-28 10:35:28.760057716 +0200 > @@ -10422,10 +10422,35 @@ expand_expr_real_1 (tree exp, rtx target > { > if (bitpos == 0 > && bitsize == GET_MODE_BITSIZE (GET_MODE (op0)) > - && COMPLEX_MODE_P (mode1)) > + && COMPLEX_MODE_P (mode1) > + && COMPLEX_MODE_P (GET_MODE (op0)) > + && (GET_MODE_PRECISION (GET_MODE_INNER (mode1)) > + == GET_MODE_PRECISION (GET_MODE_INNER (GET_MODE (op0))))) > { > if (reversep) > op0 = flip_storage_order (GET_MODE (op0), op0); > + if (mode1 != GET_MODE (op0)) > + { > + rtx parts[2]; > + for (int i = 0; i < 2; i++) > + { > + rtx op = read_complex_part (op0, i != 0); > + if (GET_CODE (op) == SUBREG) > + op = force_reg (GET_MODE (op), op); > + rtx temp = gen_lowpart_common (GET_MODE_INNER (mode1), > + op); > + if (temp) > + op = temp; > + else > + { > + if (!REG_P (op) && !MEM_P (op)) > + op = force_reg (GET_MODE (op), op); > + op = gen_lowpart (GET_MODE_INNER (mode1), op); > + } > + parts[i] = op; > + } > + op0 = gen_rtx_CONCAT (mode1, parts[0], parts[1]); > + } > return op0; > } > if (bitpos == 0 > --- gcc/testsuite/g++.dg/torture/pr77919-2.C.jj 2016-10-28 10:35:49.294798140 +0200 > +++ gcc/testsuite/g++.dg/torture/pr77919-2.C 2016-10-28 10:29:38.000000000 +0200 > @@ -0,0 +1,10 @@ > +// PR rtl-optimization/77919 > +// { dg-do compile } > + > +typedef _Complex long long B; > +struct A { A (double) {} _Complex double i; }; > +typedef struct { B b; } C; > +struct D { D (const B &x) : b (x) {} B b; }; > +static inline B foo (const double *x) { C *a; a = (C *) x; return a->b; } > +static inline D baz (const A &x) { return foo ((double *) &x); } > +D b = baz (0); > > > Jakub > > -- Richard Biener SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)