From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by sourceware.org (Postfix) with ESMTPS id 149EC3858D26 for ; Mon, 7 Nov 2022 20:07:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 149EC3858D26 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-x529.google.com with SMTP id u24so19307993edd.13 for ; Mon, 07 Nov 2022 12:07:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=UUXB3mWblhoZsMpf6ilV1xcPWkQymThbiJ4VRCMJSSk=; b=AGcOqZbDN3jmHcoxkkmokGdDCebEkQ2ZAgRLSQP/a4EfMKNg556SKGkbxIGsfVTCDl Q6Ep6xCvqQsmMgG8H2sccN0Rwq36AOhMGce401rvMLdhpPv03IcDBx6AOyBC14zN/FwV dvvNM68fqqt/91FObWTtgtVSnnB33skAGWo5VUE1M4/PqqEtL3Ie4PVch0OOJB6frH6o Y3Vxff03eWEyID6gT7SrF+JyBuxb4T5WDLyhnjn8+f50xSRJ4S2XXlHfIzKJiRPPdPhf v0AzVx3z9frnRXbjL6TCEncw8r5f2oBOpiBlMy0NYWg5C5kBpRP1lP9dD5kHOzvWyKYe XDwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UUXB3mWblhoZsMpf6ilV1xcPWkQymThbiJ4VRCMJSSk=; b=5E7uadxATUtSh18j/fCM8bGkBzgBev83axSyqqKF+Zv8TsflssAatcP2uuSTnm4Wzc s3WYW3QQl2YgmggyqeV+10bACduy3IZVEsyJ2AejJ54P+w2NcbyA+bJMJQcGTAO9/c4q RHf3jax40lequ6h1cmVVdrebX+kqcbIuoDQO8Dpkwaz6gLd5UVzWPA5bgnIKDhdat+vm hXgAMalraflWK5AAEPEvhNwpzaWKnoRg6KoEHOGDYq7+PiwsMm3bn+IYjmwh6euPa3Kj uRaBR6xHkXFL1mIF7+l6SWxX4uoULrIJsRK/TZixczc2/zw6zZUOv0MTFIcHqZhlJfGW dkqw== X-Gm-Message-State: ACrzQf3VvpVSBAHV/xKqvwkGelyGWhH8szrb23z5SFp6b0RpqwzX8xwW htr0rWZTazBG2OwLXiuKRBZbQQ322SN3WTTiqjw= X-Google-Smtp-Source: AMsMyM5En5HunGZd5K6h1wV4wDnQ6HRaGDunTay6lZfd8B6HZjcSpnrgEolowO2gWd7pGud7+0Z0/v8YuIraUuEsm58= X-Received: by 2002:a05:6402:274c:b0:461:9921:60cf with SMTP id z12-20020a056402274c00b00461992160cfmr52848914edd.353.1667851657668; Mon, 07 Nov 2022 12:07:37 -0800 (PST) MIME-Version: 1.0 References: <20221020165734.1113688-1-hjl.tools@gmail.com> In-Reply-To: From: "H.J. Lu" Date: Mon, 7 Nov 2022 12:07:00 -0800 Message-ID: Subject: Re: [PATCH v2] Always use TYPE_MODE instead of DECL_MODE for vector field To: Richard Biener Cc: Jakub Jelinek , GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3023.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, Oct 24, 2022 at 11:28 PM Richard Biener wrote: > > On Mon, Oct 24, 2022 at 10:02 PM H.J. Lu wrote: > > > > On Mon, Oct 24, 2022 at 12:12 AM Richard Biener > > wrote: > > > > > > On Fri, Oct 21, 2022 at 6:18 PM H.J. Lu wrote: > > > > > > > > On Fri, Oct 21, 2022 at 2:33 AM Richard Biener > > > > wrote: > > > > > > > > > > On Thu, Oct 20, 2022 at 6:58 PM H.J. Lu via Gcc-patches > > > > > wrote: > > > > > > > > > > > > commit e034c5c895722e0092d2239cd8c2991db77d6d39 > > > > > > Author: Jakub Jelinek > > > > > > Date: Sat Dec 2 08:54:47 2017 +0100 > > > > > > > > > > > > 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. > > > > > > > > > > > > fixed the case where DECL_MODE of a vector field is BLKmode and its > > > > > > TYPE_MODE is a vector mode because of target attribute. Remove the > > > > > > BLKmode check for the case where DECL_MODE of a vector field is a vector > > > > > > mode and its TYPE_MODE is BLKmode because of target attribute. > > > > > > > > > > > > gcc/ > > > > > > > > > > > > PR target/107304 > > > > > > * expr.c (get_inner_reference): Always use TYPE_MODE for vector > > > > > > field with vector raw mode. > > > > > > > > > > > > gcc/testsuite/ > > > > > > > > > > > > PR target/107304 > > > > > > * gcc.target/i386/pr107304.c: New test. > > > > > > --- > > > > > > gcc/expr.cc | 3 +- > > > > > > gcc/testsuite/gcc.target/i386/pr107304.c | 39 ++++++++++++++++++++++++ > > > > > > 2 files changed, 40 insertions(+), 2 deletions(-) > > > > > > create mode 100644 gcc/testsuite/gcc.target/i386/pr107304.c > > > > > > > > > > > > diff --git a/gcc/expr.cc b/gcc/expr.cc > > > > > > index efe387e6173..9145193c2c1 100644 > > > > > > --- a/gcc/expr.cc > > > > > > +++ b/gcc/expr.cc > > > > > > @@ -7905,8 +7905,7 @@ get_inner_reference (tree exp, poly_int64_pod *pbitsize, > > > > > > /* 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)) > > > > > > + if (VECTOR_TYPE_P (TREE_TYPE (field)) > > > > > > && VECTOR_MODE_P (TYPE_MODE_RAW (TREE_TYPE (field)))) > > > > > > > > > > Isn't the check on TYPE_MODE_RAW also wrong then? Btw, the mode could > > > > > > > > TYPE_MODE_RAW is always set to a vector mode for a vector type: > > > > > > > > /* Find an appropriate mode for the vector type. */ > > > > if (TYPE_MODE (type) == VOIDmode) > > > > SET_TYPE_MODE (type, > > > > mode_for_vector (SCALAR_TYPE_MODE (innertype), > > > > nunits).else_blk ()); > > > > > > But mode_for_vector can return a MODE_INT! > > > > You are right. > > > > > /* For integers, try mapping it to a same-sized scalar mode. */ > > > if (GET_MODE_CLASS (innermode) == MODE_INT) > > > { > > > poly_uint64 nbits = nunits * GET_MODE_BITSIZE (innermode); > > > if (int_mode_for_size (nbits, 0).exists (&mode) > > > && have_regs_of_mode[mode]) > > > return mode; > > > > > > > But TYPE_MODE returns BLKmode if the vector mode is unsupported. > > > > > > > > > also be an integer mode. > > > > > > > > For a vector field, mode is either BLK mode or the vector mode. Jakub, > > > > can you comment on it? > > > > > > I think that for > > > > > > typedef int v2si __attribute__((vector_size(8))); > > > > > > struct X { int i; v2si j; }; > > > > > > v2si should get DImode with -mno-sse? > > > > > > > Currently GCC generates > > > > (insn 31 32 33 (set (subreg:DI (reg:V2SI 105) 0) > > (reg:DI 84 [ _3 ])) "y2.c":12:11 -1 > > (nil)) > > > > With my patch, v2si gets DImode directly without SUBREG. > > > > Here is the v2 patch with the update commit message: > > > > Remove the BLKmode check for the case where DECL_MODE > > of a vector field is a vector mode and its TYPE_MODE isn't a > > vector mode because of target attribute. > > > > OK for master? > > OK. OK to backport to release branches? Thanks. -- H.J.