From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by sourceware.org (Postfix) with ESMTPS id B87093858C50 for ; Thu, 9 Feb 2023 08:16:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B87093858C50 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-lj1-x233.google.com with SMTP id g14so1148344ljh.10 for ; Thu, 09 Feb 2023 00:16:31 -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=mkeHea1jblBQfD9cu0bKBXkWvw2GIIyjbcQfSjOqysk=; b=VBJw5da0WO2mu888PJ0OwuF9EU3QravQHYigjJwguseSqfP7wh775Wz0kb4bipJBmA 91M7KaO/3ej5PB9mQ7gPTcqu23nMI516fiBX70f2R8EuqlWTsU4ZIx1gabDkIUxetjaS c++NvOzGXAx0DcN/a6baz2nY6DinmUzJh2TqaJFlBsiCaWtmjIh3wGNkZX3KNth2oYg+ afWtiz937fvRi5xrhUEJ1ktNDEZ9xHLCkSYtbjPZQ6Im5A8NiaamlZQtS1oCU8HyPVvf BDGAe1CcB6DGEXwxE948c8x64Wfm0weXoe6f7MQIQzQrY66Gd9Kw2TA3Ulr1miP3kxaE 1H9g== 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=mkeHea1jblBQfD9cu0bKBXkWvw2GIIyjbcQfSjOqysk=; b=BJ2F6UC1TrbRG/9hnlFaLIJ9hAR11AxjaNAxjpBvU1E4Z1oMy990jyujXoRyMggBNW 8B7lsFi9JANQELiYcRnJb0AI3BlbiZ2HyaYMPnjYQKLIHKGCWArnXMz4GzyVw3YK6rgi PT/eAZ9b6G+cExAk+Z/4+I+tA7IX9ogS+1ISLWmz+S7TXUCvQWwCiHPPbONlsj7d76fS 1EU4bS/PXWrho8jL997paePvAfTQ7zQbPWEgZSF7Wd75XwhQfAkZG7EoI827JH5WV0Um IV19CwVLez2H0jTEqncXTMdeHudnPMs2geTZsLJ6NPSK8u0FnT6+XGYpdGSTvna3UJSK wI0g== X-Gm-Message-State: AO0yUKUkHypLKrx5m2HeuI6yog6ZiXezRzDDVCOnqZeBNzjGhjsR5D6U IgKPhBmoTJ3+kj6Uj1VtevWZOZ5dMtboVfHmv9w= X-Google-Smtp-Source: AK7set9d7DP9QoAtvnyDBDIwTgZUwAJ/3PvdYp+Snxtuogf3ZTb6dXgaFNN4DQCr19qh2Ufbfe08Grwjk0GM1OBfKAY= X-Received: by 2002:a2e:960b:0:b0:293:3152:74b1 with SMTP id v11-20020a2e960b000000b00293315274b1mr160125ljh.186.1675930590297; Thu, 09 Feb 2023 00:16:30 -0800 (PST) MIME-Version: 1.0 References: <20230208211419.1583473-1-apinski@marvell.com> In-Reply-To: <20230208211419.1583473-1-apinski@marvell.com> From: Richard Biener Date: Thu, 9 Feb 2023 09:16:17 +0100 Message-ID: Subject: Re: [PATCH] When simplifing BFR of an insert, require a mode precision integral type (PR108688) To: Andrew Pinski Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,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 Wed, Feb 8, 2023 at 10:15 PM Andrew Pinski via Gcc-patches wrote: > > The same problem as PR 88739 has crept in but > this time in match.pd when simplifying bit_field_ref of > an bit_insert. That is we are generating a BIT_FIELD_REF > of a non-mode-precision integral type. > > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. Hmm. Can we handle the case of the extraction exactly covering the insertion separately then and simplify to plain @1? Thanks, Richard. > PR tree-optimization/108688 > > gcc/ChangeLog: > > * match.pd (bit_field_ref [bit_insert]): > Avoid generating BIT_FIELD_REFs of non-mode-precision > integral operands > > gcc/testsuite/ChangeLog: > > * gcc.c-torture/compile/pr108688-1.c: New test. > --- > gcc/match.pd | 4 +++- > gcc/testsuite/gcc.c-torture/compile/pr108688-1.c | 15 +++++++++++++++ > 2 files changed, 18 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr108688-1.c > > diff --git a/gcc/match.pd b/gcc/match.pd > index c9e8bebede2..d8353072822 100644 > --- a/gcc/match.pd > +++ b/gcc/match.pd > @@ -7487,7 +7487,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > isize = tree_to_uhwi (TYPE_SIZE (TREE_TYPE (@1))); > } > (switch > - (if (wi::leu_p (wi::to_wide (@ipos), wi::to_wide (@rpos)) > + (if ((!INTEGRAL_TYPE_P (TREE_TYPE (@1)) > + || type_has_mode_precision_p (TREE_TYPE (@1))) > + && wi::leu_p (wi::to_wide (@ipos), wi::to_wide (@rpos)) > && wi::leu_p (wi::to_wide (@rpos) + wi::to_wide (@rsize), > wi::to_wide (@ipos) + isize)) > (BIT_FIELD_REF @1 @rsize { wide_int_to_tree (bitsizetype, > diff --git a/gcc/testsuite/gcc.c-torture/compile/pr108688-1.c b/gcc/testsuite/gcc.c-torture/compile/pr108688-1.c > new file mode 100644 > index 00000000000..43d782d62bd > --- /dev/null > +++ b/gcc/testsuite/gcc.c-torture/compile/pr108688-1.c > @@ -0,0 +1,15 @@ > + > + > +union U { signed int d : 7; signed int e : 2; } u; > +int a, b; > + > +void > +foo (void) > +{ > + for (int i = 0; i < 64; i++) > + { > + u.d = a; > + u.e ^= b; > + } > +} > + > -- > 2.17.1 >