From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 119659 invoked by alias); 2 Dec 2017 00:14:22 -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 119612 invoked by uid 89); 2 Dec 2017 00:14:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.7 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KB_WAM_FROM_NAME_SINGLEWORD,SPF_HELO_PASS,T_RP_MATCHES_RCVD 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; Sat, 02 Dec 2017 00:14:20 +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 3B039C057F93; Sat, 2 Dec 2017 00:14:19 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-77.ams2.redhat.com [10.36.116.77]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D76285D969; Sat, 2 Dec 2017 00:14:18 +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 vB20EGq5027548; Sat, 2 Dec 2017 01:14:16 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id vB20EGva027547; Sat, 2 Dec 2017 01:14:16 +0100 Date: Sat, 02 Dec 2017 00:14:00 -0000 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Small hack for DECL_MODE lack of vector_type_mode-like behavior (PR target/78643, PR target/80583) Message-ID: <20171202001415.GF2353@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-12/txt/msg00085.txt.bz2 Hi! In TYPE_MODE we have a hack for vector types where we dynamically adjust it based on whether it is used from a function where the vector mode is or isn't supported (depending on target attribute, function multiversioning, etc.), but we don't have anything like that in DECL_MODE. The following is just a small hack that should be backportable to adjust similarly DECL_MODE when looking at fields - for static VAR_DECLs we already have code to cope with that, furthermore we need to cope there with the case where DECL_RTL is created in one context and used in another one. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2017-12-01 Jakub Jelinek PR target/78643 PR target/80583 * expr.c (get_inner_reference): If DECL_MODE of a non-bitfield is BLKmode for vector field with vector raw mode, use TYPE_MODE instead of DECL_MODE. * gcc.target/i386/pr80583.c: New test. --- gcc/expr.c.jj 2017-11-27 09:27:41.000000000 +0100 +++ gcc/expr.c 2017-12-01 11:36:19.011863308 +0100 @@ -7032,7 +7032,16 @@ get_inner_reference (tree exp, HOST_WIDE size. */ mode = TYPE_MODE (DECL_BIT_FIELD_TYPE (field)); else if (!DECL_BIT_FIELD (field)) - mode = DECL_MODE (field); + { + mode = DECL_MODE (field); + /* For vector fields re-check the target flags, as DECL_MODE + could have been set with different target flags than + the current function has. */ + if (mode == BLKmode + && VECTOR_TYPE_P (TREE_TYPE (field)) + && VECTOR_MODE_P (TYPE_MODE_RAW (TREE_TYPE (field)))) + mode = TYPE_MODE (TREE_TYPE (field)); + } else if (DECL_MODE (field) == BLKmode) blkmode_bitfield = true; --- gcc/testsuite/gcc.target/i386/pr80583.c.jj 2017-12-01 11:44:28.106603314 +0100 +++ gcc/testsuite/gcc.target/i386/pr80583.c 2017-12-01 11:44:12.000000000 +0100 @@ -0,0 +1,13 @@ +/* PR target/80583 */ +/* { dg-do compile } */ +/* { dg-options "-O0 -mno-avx" } */ + +typedef int V __attribute__((__vector_size__(32))); +struct S { V a; }; + +V __attribute__((target ("avx"))) +foo (struct S *b) +{ + V x = b->a; + return x; +} Jakub