From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16091 invoked by alias); 2 Mar 2017 21:44:30 -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 16078 invoked by uid 89); 2 Mar 2017 21:44:30 -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=Hx-languages-length:2801 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; Thu, 02 Mar 2017 21:44:29 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 75A0F81252; Thu, 2 Mar 2017 21:44:29 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-117-76.ams2.redhat.com [10.36.117.76]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v22LiR4Q021190 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 2 Mar 2017 16:44:29 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id v22LiPv9020239; Thu, 2 Mar 2017 22:44:25 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id v22LiJRa020238; Thu, 2 Mar 2017 22:44:19 +0100 Date: Thu, 02 Mar 2017 21:44:00 -0000 From: Jakub Jelinek To: Uros Bizjak Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix -O0 -ffloat-store -mavx ICE (PR target/79807) Message-ID: <20170302214419.GT1849@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-03/txt/msg00136.txt.bz2 Hi! For -O1 and above, we force all operands and targets of x86 builtins into registers during expansion, because we expect combiner will do its job. But for -O0, we try to keep them in MEM if the predicate allows it, we just make sure that at most one input operand is a MEM. We still allow MEM destination and one MEM input operand, which is why we ICE - most insns/expanders don't allow that in the predicates and it is fine, but various insns/expanders have e.g. nonimmediate_operand on both target and some input operand and just have a condition that requires that one of those is a register or that both of them are not memory. The expanders don't check the condition though, it is checked only when the insn is being recognized in vregs pass and that is too late. The following patch fixes that by forcing all input operands at -O0 into non-memory if the target is memory. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? Or are there any define_insn/define_expand where it is desirable to have both input and output operand a MEM (and does it have to be matching)? For various scalar binary and unary expanders the backend already uses a helper that will force something into memory if dest and src are both memory and not rtx_equal_p, but do we have anything like that in anything these two builtin expanders emit? 2017-03-02 Jakub Jelinek PR target/79807 * config/i386/i386.c (ix86_expand_multi_arg_builtin): If target is a memory operand, increase num_memory. (ix86_expand_args_builtin): Likewise. * gcc.target/i386/pr79807.c: New test. --- gcc/config/i386/i386.c.jj 2017-03-02 08:08:43.000000000 +0100 +++ gcc/config/i386/i386.c 2017-03-02 17:58:28.396999033 +0100 @@ -34249,6 +34249,8 @@ ix86_expand_multi_arg_builtin (enum insn || GET_MODE (target) != tmode || !insn_data[icode].operand[0].predicate (target, tmode)) target = gen_reg_rtx (tmode); + else if (memory_operand (target, tmode)) + num_memory++; gcc_assert (nargs <= 4); @@ -35534,6 +35536,8 @@ ix86_expand_args_builtin (const struct b || GET_MODE (target) != tmode || !insn_p->operand[0].predicate (target, tmode)) target = gen_reg_rtx (tmode); + else if (memory_operand (target, tmode)) + num_memory++; real_target = target; } else --- gcc/testsuite/gcc.target/i386/pr79807.c.jj 2017-03-02 18:03:30.032023436 +0100 +++ gcc/testsuite/gcc.target/i386/pr79807.c 2017-03-02 18:02:53.000000000 +0100 @@ -0,0 +1,12 @@ +/* PR target/79807 */ +/* { dg-do compile } */ +/* { dg-options "-O0 -mavx -ffloat-store" } */ + +typedef double __v2df __attribute__ ((__vector_size__ (16))); +typedef double __v4df __attribute__ ((__vector_size__ (32))); + +__v2df +foo (__v4df x) +{ + return __builtin_ia32_pd_pd256 (x); +} Jakub