From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1709371-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 258E515813A
	for <garchives@archives.gentoo.org>; Tue, 14 Jan 2025 16:22:30 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 40866E0819;
	Tue, 14 Jan 2025 16:22:29 +0000 (UTC)
Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 27ADCE0819
	for <gentoo-commits@lists.gentoo.org>; Tue, 14 Jan 2025 16:22:29 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 5624B340A12
	for <gentoo-commits@lists.gentoo.org>; Tue, 14 Jan 2025 16:22:28 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id CA17FB2C
	for <gentoo-commits@lists.gentoo.org>; Tue, 14 Jan 2025 16:22:26 +0000 (UTC)
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org>
Message-ID: <1736871737.5c4e50d6f18794b3bece70beadb05d256087f45d.sam@gentoo>
Subject: [gentoo-commits] proj/gcc-patches:master commit in: 15.0.0/gentoo/
X-VCS-Repository: proj/gcc-patches
X-VCS-Files: 15.0.0/gentoo/84_all_PR118456-check-and-extend-constants-to-compare-with-bitfields.patch 15.0.0/gentoo/README.history
X-VCS-Directories: 15.0.0/gentoo/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: 5c4e50d6f18794b3bece70beadb05d256087f45d
X-VCS-Branch: master
Date: Tue, 14 Jan 2025 16:22:26 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: 79b19abc-6117-48be-9ca1-a22276ef5e23
X-Archives-Hash: 78da3c159d9049f4c53389f2febe27bf

commit:     5c4e50d6f18794b3bece70beadb05d256087f45d
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 14 16:22:17 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Jan 14 16:22:17 2025 +0000
URL:        https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=5c4e50d6

15.0.0: drop upstream ifcombine patch

Merged upstream.

Signed-off-by: Sam James <sam <AT> gentoo.org>

 ...xtend-constants-to-compare-with-bitfields.patch | 214 ---------------------
 15.0.0/gentoo/README.history                       |   1 +
 2 files changed, 1 insertion(+), 214 deletions(-)

diff --git a/15.0.0/gentoo/84_all_PR118456-check-and-extend-constants-to-compare-with-bitfields.patch b/15.0.0/gentoo/84_all_PR118456-check-and-extend-constants-to-compare-with-bitfields.patch
deleted file mode 100644
index e005c02..0000000
--- a/15.0.0/gentoo/84_all_PR118456-check-and-extend-constants-to-compare-with-bitfields.patch
+++ /dev/null
@@ -1,214 +0,0 @@
-https://inbox.sourceware.org/gcc-patches/ora5bugmmi.fsf@lxoliva.fsfla.org/
-
-From 4e794a3a5de8e8fa0fcaf98e5ea298d4a3c71192 Mon Sep 17 00:00:00 2001
-Message-ID: <4e794a3a5de8e8fa0fcaf98e5ea298d4a3c71192.1736844127.git.sam@gentoo.org>
-From: Alexandre Oliva <oliva@adacore.com>
-Date: Mon, 13 Jan 2025 23:22:45 -0300
-Subject: [PATCH 1/2] check and extend constants to compare with bitfields
- [PR118456]
-
-Add logic to check and extend constants compared with bitfields, so
-that fields are only compared with constants they could actually
-equal.  This involves making sure the signedness doesn't change
-between loads and conversions before shifts: we'd need to carry a lot
-more data to deal with all the possibilities.
-
-Regstrapped on x86_64-linux-gnu.  Ok to install?
-
-for  gcc/ChangeLog
-
-	PR tree-optimization/118456
-	* gimple-fold.cc (decode_field_reference): Punt if shifting
-	after changing signedness.
-	(fold_truth_andor_for_ifcombine): Check extension bits in
-	constants before clipping.
-
-for  gcc/testsuite/ChangeLog
-
-PR tree-optimization/118456
-	* gcc.dg/field-merge-21.c: New.
-	* gcc.dg/field-merge-22.c: New.
----
- gcc/gimple-fold.cc                    | 40 +++++++++++++++++++-
- gcc/testsuite/gcc.dg/field-merge-21.c | 53 +++++++++++++++++++++++++++
- gcc/testsuite/gcc.dg/field-merge-22.c | 31 ++++++++++++++++
- 3 files changed, 122 insertions(+), 2 deletions(-)
- create mode 100644 gcc/testsuite/gcc.dg/field-merge-21.c
- create mode 100644 gcc/testsuite/gcc.dg/field-merge-22.c
-
-diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
-index 93ed8b3abb05..5b1fbe6db1df 100644
---- a/gcc/gimple-fold.cc
-+++ b/gcc/gimple-fold.cc
-@@ -7712,6 +7712,18 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT *pbitsize,
- 
-   if (shiftrt)
-     {
-+      /* Punt if we're shifting by more than the loaded bitfield (after
-+	 adjustment), or if there's a shift after a change of signedness, punt.
-+	 When comparing this field with a constant, we'll check that the
-+	 constant is a proper sign- or zero-extension (depending on signedness)
-+	 of a value that would fit in the selected portion of the bitfield.  A
-+	 shift after a change of signedness would make the extension
-+	 non-uniform, and we can't deal with that (yet ???).  See
-+	 gcc.dg/field-merge-22.c for a test that would go wrong.  */
-+      if (*pbitsize <= shiftrt
-+	  || (convert_before_shift
-+	      && outer_type && unsignedp != TYPE_UNSIGNED (outer_type)))
-+	return NULL_TREE;
-       if (!*preversep ? !BYTES_BIG_ENDIAN : BYTES_BIG_ENDIAN)
- 	*pbitpos += shiftrt;
-       *pbitsize -= shiftrt;
-@@ -8512,13 +8524,25 @@ fold_truth_andor_for_ifcombine (enum tree_code code, tree truth_type,
-      and bit position.  */
-   if (l_const.get_precision ())
-     {
-+      /* Before clipping upper bits of the right-hand operand of the compare,
-+	 check that they're sign or zero extensions, depending on how the
-+	 left-hand operand would be extended.  */
-+      bool l_non_ext_bits = false;
-+      if (ll_bitsize < lr_bitsize)
-+	{
-+	  wide_int zext = wi::zext (l_const, ll_bitsize);
-+	  if ((ll_unsignedp ? zext : wi::sext (l_const, ll_bitsize)) == l_const)
-+	    l_const = zext;
-+	  else
-+	    l_non_ext_bits = true;
-+	}
-       /* We're doing bitwise equality tests, so don't bother with sign
- 	 extensions.  */
-       l_const = wide_int::from (l_const, lnprec, UNSIGNED);
-       if (ll_and_mask.get_precision ())
- 	l_const &= wide_int::from (ll_and_mask, lnprec, UNSIGNED);
-       l_const <<= xll_bitpos;
--      if ((l_const & ~ll_mask) != 0)
-+      if (l_non_ext_bits || (l_const & ~ll_mask) != 0)
- 	{
- 	  warning_at (lloc, OPT_Wtautological_compare,
- 		      "comparison is always %d", wanted_code == NE_EXPR);
-@@ -8530,11 +8554,23 @@ fold_truth_andor_for_ifcombine (enum tree_code code, tree truth_type,
- 	 again.  */
-       gcc_checking_assert (r_const.get_precision ());
- 
-+      /* Before clipping upper bits of the right-hand operand of the compare,
-+	 check that they're sign or zero extensions, depending on how the
-+	 left-hand operand would be extended.  */
-+      bool r_non_ext_bits = false;
-+      if (rl_bitsize < rr_bitsize)
-+	{
-+	  wide_int zext = wi::zext (r_const, rl_bitsize);
-+	  if ((rl_unsignedp ? zext : wi::sext (r_const, rl_bitsize)) == r_const)
-+	    r_const = zext;
-+	  else
-+	    r_non_ext_bits = true;
-+	}
-       r_const = wide_int::from (r_const, lnprec, UNSIGNED);
-       if (rl_and_mask.get_precision ())
- 	r_const &= wide_int::from (rl_and_mask, lnprec, UNSIGNED);
-       r_const <<= xrl_bitpos;
--      if ((r_const & ~rl_mask) != 0)
-+      if (r_non_ext_bits || (r_const & ~rl_mask) != 0)
- 	{
- 	  warning_at (rloc, OPT_Wtautological_compare,
- 		      "comparison is always %d", wanted_code == NE_EXPR);
-diff --git a/gcc/testsuite/gcc.dg/field-merge-21.c b/gcc/testsuite/gcc.dg/field-merge-21.c
-new file mode 100644
-index 000000000000..042b2123eb63
---- /dev/null
-+++ b/gcc/testsuite/gcc.dg/field-merge-21.c
-@@ -0,0 +1,53 @@
-+/* { dg-do run } */
-+/* { dg-options "-O2" } */
-+
-+/* PR tree-optimization/118456 */
-+/* Check that shifted fields compared with a constants compare correctly even
-+   if the constant contains sign-extension bits not present in the bit
-+   range.  */
-+
-+struct S { unsigned long long o; unsigned short a, b; } s;
-+
-+__attribute__((noipa)) int
-+foo (void)
-+{
-+  return ((unsigned char) s.a) >> 3 == 17 && ((signed char) s.b) >> 2 == -27;
-+}
-+
-+__attribute__((noipa)) int
-+bar (void)
-+{
-+  return ((unsigned char) s.a) >> 3 == 17 && ((signed char) s.b) >> 2 == -91;
-+}
-+
-+__attribute__((noipa)) int
-+bars (void)
-+{
-+  return ((unsigned char) s.a) >> 3 == 17 && ((signed char) s.b) >> 2 == 37;
-+}
-+
-+__attribute__((noipa)) int
-+baz (void)
-+{
-+  return ((unsigned char) s.a) >> 3 == 49 && ((signed char) s.b) >> 2 == -27;
-+}
-+
-+__attribute__((noipa)) int
-+bazs (void)
-+{
-+  return ((unsigned char) s.a) >> 3 == (unsigned char) -15 && ((signed char) s.b) >> 2 == -27;
-+}
-+
-+int
-+main ()
-+{
-+  s.a = 17 << 3;
-+  s.b = (unsigned short)(-27u << 2);
-+  if (foo () != 1
-+      || bar () != 0
-+      || bars () != 0
-+      || baz () != 0
-+      || bazs () != 0)
-+    __builtin_abort ();
-+  return 0;
-+}
-diff --git a/gcc/testsuite/gcc.dg/field-merge-22.c b/gcc/testsuite/gcc.dg/field-merge-22.c
-new file mode 100644
-index 000000000000..45b29c0bccaf
---- /dev/null
-+++ b/gcc/testsuite/gcc.dg/field-merge-22.c
-@@ -0,0 +1,31 @@
-+/* { dg-do run } */
-+/* { dg-options "-O2" } */
-+
-+/* PR tree-optimization/118456 */
-+/* Check that compares with constants take into account sign/zero extension of
-+   both the bitfield and of the shifting type.  */
-+
-+#define shift (__CHAR_BIT__ - 4)
-+
-+struct S {
-+  signed char a : shift + 2;
-+  signed char b : shift + 2;
-+  short ignore[0];
-+} s;
-+
-+__attribute__((noipa)) int
-+foo (void)
-+{
-+  return ((unsigned char) s.a) >> shift == 15
-+    && ((unsigned char) s.b) >> shift == 0;
-+}
-+
-+int
-+main ()
-+{
-+  s.a = -1;
-+  s.b = 1;
-+  if (foo () != 1)
-+    __builtin_abort ();
-+  return 0;
-+}
-
-base-commit: 31c3c1a83fd885b4687c9f6f7acd68af76d758d3
--- 
-2.48.0
-

diff --git a/15.0.0/gentoo/README.history b/15.0.0/gentoo/README.history
index 0607277..02c646e 100644
--- a/15.0.0/gentoo/README.history
+++ b/15.0.0/gentoo/README.history
@@ -1,5 +1,6 @@
 41	????
 
+	- 84_all_PR118456-check-and-extend-constants-to-compare-with-bitfields.patch
 	- 86_all_PR118418-Fix-build-for-STORE_FLAG_VALUE-0-targets.patch
 
 40	14 January 2025