From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 60224 invoked by alias); 4 Apr 2017 19:24:54 -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 60212 invoked by uid 89); 4 Apr 2017 19:24:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= 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 ESMTP; Tue, 04 Apr 2017 19:24:52 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EE49061B97; Tue, 4 Apr 2017 19:24:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EE49061B97 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com EE49061B97 Received: from tucnak.zalov.cz (ovpn-116-72.ams2.redhat.com [10.36.116.72]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 714D17DB5F; Tue, 4 Apr 2017 19:24:51 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id v34JOmD9027618; Tue, 4 Apr 2017 21:24:49 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id v34JOmLZ027617; Tue, 4 Apr 2017 21:24:48 +0200 Date: Tue, 04 Apr 2017 19:24:00 -0000 From: Jakub Jelinek To: Uros Bizjak Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Don't error about x86 return value in SSE reg (or x86 reg) or argument in SSE reg too early (PR target/80298) Message-ID: <20170404192447.GL17461@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes X-SW-Source: 2017-04/txt/msg00182.txt.bz2 Hi! aggregate_value_p is called often very early during compilation, e.g. from allocate_function or during gimplification of a call with lhs. The problem with that is e.g. that on x86_64 -m64 -mno-sse we can't include , because the always_inline inline functions in mmx and 3dnow intrinsic headers return __m64 or take __m64 as arguments and that in the 64-bit ABI is in SSE register. The following patch makes sure we diagnose this only later (e.g. when expanding a function to RTL or when expanding calls to other functions), which means we don't diagnose e.g. inline functions that got successfully inlined (because then there is really no function return in SSE or x87 reg) or e.g. for builtin calls if they are emitted inline rather than as a library call (again, I think that is desirable). I had to tweak a few tests because the reported line changed slightly, and in the last test add -fno-builtin-fminl, because otherwise fminl is expanded inline and again there is no call left with the problem. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2017-04-04 Jakub Jelinek PR target/80298 * config/i386/i386.c (construct_container): Postpone errors about return values or arguments in SSE or x87 registers with those disabled until inlining is done. * gcc.target/i386/pr80298-1.c: New test. * gcc.target/i386/pr80298-2.c: New test. * gcc.target/i386/pr57655.c: Adjust expected diagnostic line. * gcc.target/i386/pr59794-6.c: Likewise. * gcc.target/i386/pr70738-1.c: Likewise. Add -Wno-psabi to dg-options. * gcc.target/i386/pr68473-1.c: Add -fno-builtin-fminl to dg-options. --- gcc/config/i386/i386.c.jj 2017-04-04 19:51:33.661684106 +0200 +++ gcc/config/i386/i386.c 2017-04-04 20:45:42.573366752 +0200 @@ -9330,7 +9330,12 @@ construct_container (machine_mode mode, some less clueful developer tries to use floating-point anyway. */ if (needed_sseregs && !TARGET_SSE) { - if (in_return) + /* Don't diagnose anything until after inlining, we might have + functions with such arguments that are just always inlined + and don't really need SSE returns or arguments. */ + if (symtab->state < IPA_SSA_AFTER_INLINING) + ; + else if (in_return) { if (!issued_sse_ret_error) { @@ -9354,7 +9359,11 @@ construct_container (machine_mode mode, || regclass[i] == X86_64_X87UP_CLASS || regclass[i] == X86_64_COMPLEX_X87_CLASS) { - if (!issued_x87_ret_error) + /* Don't diagnose anything until after inlining, we might have + functions with such arguments that are just always inlined + and don't really need x87 returns. */ + if (symtab->state >= IPA_SSA_AFTER_INLINING + && !issued_x87_ret_error) { error ("x87 register return with x87 disabled"); issued_x87_ret_error = true; --- gcc/testsuite/gcc.target/i386/pr80298-1.c.jj 2017-04-04 20:45:42.574366739 +0200 +++ gcc/testsuite/gcc.target/i386/pr80298-1.c 2017-04-04 20:45:42.574366739 +0200 @@ -0,0 +1,7 @@ +/* PR target/80298 */ +/* { dg-do compile } */ +/* { dg-options "-mno-sse -mmmx" } */ + +#include + +int i; --- gcc/testsuite/gcc.target/i386/pr80298-2.c.jj 2017-04-04 20:45:42.574366739 +0200 +++ gcc/testsuite/gcc.target/i386/pr80298-2.c 2017-04-04 20:45:42.574366739 +0200 @@ -0,0 +1,7 @@ +/* PR target/80298 */ +/* { dg-do compile } */ +/* { dg-options "-mno-sse -mmmx -O2" } */ + +#include + +int i; --- gcc/testsuite/gcc.target/i386/pr57655.c.jj 2016-05-22 12:20:31.000000000 +0200 +++ gcc/testsuite/gcc.target/i386/pr57655.c 2017-04-04 20:48:31.867154730 +0200 @@ -1,7 +1,7 @@ /* { dg-do compile } */ /* { dg-options "-mavx -mvzeroupper -mno-fp-ret-in-387" } -/* { dg-error "x87 register return with x87 disabled" "" { target { ! ia32 } } 8 } */ +/* { dg-error "x87 register return with x87 disabled" "" { target { ! ia32 } } 7 } */ long double foo (long double x) --- gcc/testsuite/gcc.target/i386/pr59794-6.c.jj 2014-01-15 08:11:25.000000000 +0100 +++ gcc/testsuite/gcc.target/i386/pr59794-6.c 2017-04-04 20:49:21.820502031 +0200 @@ -8,7 +8,7 @@ typedef int __v4si __attribute__ ((__vec extern __v4si x; __v4si -foo (void) -{ /* { dg-error "SSE register return with SSE disabled" } */ +foo (void) /* { dg-error "SSE register return with SSE disabled" } */ +{ return x; } --- gcc/testsuite/gcc.target/i386/pr70738-1.c.jj 2016-05-26 10:37:56.000000000 +0200 +++ gcc/testsuite/gcc.target/i386/pr70738-1.c 2017-04-04 20:54:32.750439367 +0200 @@ -1,9 +1,9 @@ /* { dg-do compile { target { ! ia32 } } } */ -/* { dg-options "-msse2 -mgeneral-regs-only" } */ +/* { dg-options "-msse2 -mgeneral-regs-only -Wno-psabi" } */ typedef int int32x2_t __attribute__ ((__vector_size__ ((8)))); -int32x2_t test (int32x2_t a, int32x2_t b) -{ /* { dg-error "SSE register return with SSE disabled" } */ +int32x2_t test (int32x2_t a, int32x2_t b) /* { dg-error "SSE register return with SSE disabled" } */ +{ return a + b; } --- gcc/testsuite/gcc.target/i386/pr68473-1.c.jj 2015-12-31 01:11:11.000000000 +0100 +++ gcc/testsuite/gcc.target/i386/pr68473-1.c 2017-04-04 21:08:26.668514992 +0200 @@ -1,5 +1,5 @@ /* { dg-do compile { target { ! ia32 } } } */ -/* { dg-options "-fdiagnostics-show-caret -mno-fp-ret-in-387" } */ +/* { dg-options "-fdiagnostics-show-caret -mno-fp-ret-in-387 -fno-builtin-fminl" } */ extern long double fminl (long double __x, long double __y); Jakub