From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 95310 invoked by alias); 28 Apr 2015 10:06:31 -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 95277 invoked by uid 89); 28 Apr 2015 10:06:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 28 Apr 2015 10:06:29 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3SA6QZc009200 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 28 Apr 2015 06:06:26 -0400 Received: from redhat.com (ovpn-204-27.brq.redhat.com [10.40.204.27]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3SA6MRa013489 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Tue, 28 Apr 2015 06:06:25 -0400 Date: Tue, 28 Apr 2015 10:19:00 -0000 From: Marek Polacek To: GCC Patches , Joseph Myers Subject: Re: C PATCH for c/65345 (file-scope _Atomic expansion, this time with floats) Message-ID: <20150428100621.GC11448@redhat.com> References: <20150414160845.GA6541@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150414160845.GA6541@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2015-04/txt/msg01716.txt.bz2 Ping. On Tue, Apr 14, 2015 at 06:08:45PM +0200, Marek Polacek wrote: > You were right: my earlier fix for c/65345 only handled non-float types. > This patch thus handles even the float types. The fix is analogical to the > previous: use create_tmp_var_raw and TARGET_EXPR to avoid ICE. > > This only fixes x86 though, other arches will need something similar. You'll > notice that the tests are XFAILed on arches other than i?86/x86_64, hope that > is fine. > > I have also tried > $ for i in 387 387+sse 387,sse both sse sse+387 sse,387; do ./cc1 -quiet pr65345-3.c -mfpmath=$i; done > and > $ for i in 387 387+sse 387,sse both sse sse+387 sse,387; do ./cc1 -quiet pr65345-4.c -mfpmath=$i; done > and that doesn't ICE. > Also .gimple dumps for c11-atomic-1.c with/without this patch look the same. > > Bootstrapped/regtested on x86_64-linux, ok for trunk after the non-float part > is in? > > 2015-04-14 Marek Polacek > > PR c/65345 > * config/i386/i386.c (ix86_atomic_assign_expand_fenv): Adjust to use > create_tmp_var_raw rather than create_tmp_var. > > * gcc.dg/atomic/pr65345-4.c: New test. > * gcc.dg/pr65345-3.c: New test. > > diff --git gcc/config/i386/i386.c gcc/config/i386/i386.c > index 3263656..23e9013 100644 > --- gcc/config/i386/i386.c > +++ gcc/config/i386/i386.c > @@ -51646,13 +51646,13 @@ ix86_atomic_assign_expand_fenv (tree *hold, tree *clear, tree *update) > { > if (!TARGET_80387 && !TARGET_SSE_MATH) > return; > - tree exceptions_var = create_tmp_var (integer_type_node); > + tree exceptions_var = create_tmp_var_raw (integer_type_node); > if (TARGET_80387) > { > tree fenv_index_type = build_index_type (size_int (6)); > tree fenv_type = build_array_type (unsigned_type_node, fenv_index_type); > - tree fenv_var = create_tmp_var (fenv_type); > - mark_addressable (fenv_var); > + tree fenv_var = create_tmp_var_raw (fenv_type); > + TREE_ADDRESSABLE (fenv_var) = 1; > tree fenv_ptr = build_pointer_type (fenv_type); > tree fenv_addr = build1 (ADDR_EXPR, fenv_ptr, fenv_var); > fenv_addr = fold_convert (ptr_type_node, fenv_addr); > @@ -51662,10 +51662,12 @@ ix86_atomic_assign_expand_fenv (tree *hold, tree *clear, tree *update) > tree fnclex = ix86_builtins[IX86_BUILTIN_FNCLEX]; > tree hold_fnstenv = build_call_expr (fnstenv, 1, fenv_addr); > tree hold_fnclex = build_call_expr (fnclex, 0); > - *hold = build2 (COMPOUND_EXPR, void_type_node, hold_fnstenv, > + fenv_var = build4 (TARGET_EXPR, fenv_type, fenv_var, hold_fnstenv, > + NULL_TREE, NULL_TREE); > + *hold = build2 (COMPOUND_EXPR, void_type_node, fenv_var, > hold_fnclex); > *clear = build_call_expr (fnclex, 0); > - tree sw_var = create_tmp_var (short_unsigned_type_node); > + tree sw_var = create_tmp_var_raw (short_unsigned_type_node); > tree fnstsw_call = build_call_expr (fnstsw, 0); > tree sw_mod = build2 (MODIFY_EXPR, short_unsigned_type_node, > sw_var, fnstsw_call); > @@ -51679,8 +51681,8 @@ ix86_atomic_assign_expand_fenv (tree *hold, tree *clear, tree *update) > } > if (TARGET_SSE_MATH) > { > - tree mxcsr_orig_var = create_tmp_var (unsigned_type_node); > - tree mxcsr_mod_var = create_tmp_var (unsigned_type_node); > + tree mxcsr_orig_var = create_tmp_var_raw (unsigned_type_node); > + tree mxcsr_mod_var = create_tmp_var_raw (unsigned_type_node); > tree stmxcsr = ix86_builtins[IX86_BUILTIN_STMXCSR]; > tree ldmxcsr = ix86_builtins[IX86_BUILTIN_LDMXCSR]; > tree stmxcsr_hold_call = build_call_expr (stmxcsr, 0); > diff --git gcc/testsuite/gcc.dg/atomic/pr65345-4.c gcc/testsuite/gcc.dg/atomic/pr65345-4.c > index e69de29..5bd2ca3 100644 > --- gcc/testsuite/gcc.dg/atomic/pr65345-4.c > +++ gcc/testsuite/gcc.dg/atomic/pr65345-4.c > @@ -0,0 +1,59 @@ > +/* PR c/65345 */ > +/* { dg-do run { xfail { ! "i?86-*-* x86_64-*-*" } } } */ > +/* { dg-options "" } */ > + > +#define CHECK(X) if (!(X)) __builtin_abort () > + > +_Atomic float i = 5; > +_Atomic float j = 2; > + > +void > +fn1 (float a[(int) (i = 0)]) > +{ > +} > + > +void > +fn2 (float a[(int) (i += 2)]) > +{ > +} > + > +void > +fn3 (float a[(int) ++i]) > +{ > +} > + > +void > +fn4 (float a[(int) ++i]) > +{ > +} > + > +void > +fn5 (float a[(int) ++i][(int) (j = 10)]) > +{ > +} > + > +void > +fn6 (float a[(int) (i = 7)][(int) j--]) > +{ > +} > + > +int > +main () > +{ > + float a[10]; > + float aa[10][10]; > + fn1 (a); > + CHECK (i == 0); > + fn2 (a); > + CHECK (i == 2); > + fn3 (a); > + CHECK (i == 3); > + fn4 (a); > + CHECK (i == 4); > + fn5 (aa); > + CHECK (i == 5); > + CHECK (j == 10); > + fn6 (aa); > + CHECK (i == 7); > + CHECK (j == 9); > +} > diff --git gcc/testsuite/gcc.dg/pr65345-3.c gcc/testsuite/gcc.dg/pr65345-3.c > index e69de29..bd8088a 100644 > --- gcc/testsuite/gcc.dg/pr65345-3.c > +++ gcc/testsuite/gcc.dg/pr65345-3.c > @@ -0,0 +1,36 @@ > +/* PR c/65345 */ > +/* { dg-do compile { xfail { ! "i?86-*-* x86_64-*-*" } } } */ > +/* { dg-options "" } */ > + > +_Atomic float i = 3.0f; > + > +float a1 = sizeof (i + 1.2); > +float a2 = sizeof (i = 0); > +float a3 = sizeof (i++); > +float a4 = sizeof (i--); > +float a5 = sizeof (-i); > + > +float b1 = _Alignof (i + 1); > +float b2 = _Alignof (i = 0); > +float b3 = _Alignof (i++); > +float b4 = _Alignof (i--); > +float b5 = _Alignof (-i); > + > +float c1 = i; /* { dg-error "initializer element is not constant" } */ > +float c2 = (i ? 1 : 2); /* { dg-error "initializer element is not constant" } */ > +float c3[(int) i]; /* { dg-error "variably modified" } */ > +float c4 = 0 || i; /* { dg-error "initializer element is not constant" } */ > +float c5 = (i += 10); /* { dg-error "initializer element is not constant" } */ > + > +_Static_assert (_Generic (i, float: 1, default: 0) == 1, "1"); > +_Static_assert (_Generic (i + 1, float: 1, default: 0) == 1, "2"); > +_Static_assert (_Generic (i = 0, float: 1, default: 0) == 1, "3"); > +_Static_assert (_Generic (i++, float: 1, default: 0) == 1, "4"); > +_Static_assert (_Generic (i--, float: 1, default: 0) == 1, "5"); > + > +_Atomic int sz = 2; > +void fn1 (float a[sz + 1]); > +void fn2 (float a[sz = 0]); > +void fn3 (float a[sz++]); > +void fn4 (float a[sz--]); > +void fn5 (float a[-sz]); Marek