public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jan Hubicka <hubicka@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-4227] Fix access node merging
Date: Thu,  7 Oct 2021 13:26:23 +0000 (GMT)	[thread overview]
Message-ID: <20211007132623.305533858426@sourceware.org> (raw)

https://gcc.gnu.org/g:44b61586d8640b79e78cfdb6a555200ccee8df77

commit r12-4227-g44b61586d8640b79e78cfdb6a555200ccee8df77
Author: Jan Hubicka <jh@suse.cz>
Date:   Thu Oct 7 15:26:01 2021 +0200

    Fix access node merging
    
    gcc/ChangeLog:
    
    2021-10-07  Jan Hubicka  <hubicka@ucw.cz>
    
            PR ipa/102581
            * ipa-modref-tree.h (modref_access_node::contains_p): Handle offsets
            better.
            (modref_access_node::try_merge_with): Add sanity check that there
            are no redundant entries in the list.
    
    gcc/testsuite/ChangeLog:
    
    2021-10-07  Jan Hubicka  <hubicka@ucw.cz>
    
            * g++.dg/torture/pr102581.C: New test.

Diff:
---
 gcc/ipa-modref-tree.h                   |  8 ++++--
 gcc/testsuite/g++.dg/torture/pr102581.C | 51 +++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/gcc/ipa-modref-tree.h b/gcc/ipa-modref-tree.h
index 6a9ed5ce54b..8e9b89b3e2c 100644
--- a/gcc/ipa-modref-tree.h
+++ b/gcc/ipa-modref-tree.h
@@ -110,8 +110,11 @@ struct GTY(()) modref_access_node
 	       if (!a.parm_offset_known)
 		 return false;
 	       /* Accesses are never below parm_offset, so look
-		  for smaller offset.  */
-	       if (!known_le (parm_offset, a.parm_offset))
+		  for smaller offset.
+		  If access ranges are known still allow merging
+		  when bit offsets comparsion passes.  */
+	       if (!known_le (parm_offset, a.parm_offset)
+		   && !range_info_useful_p ())
 		 return false;
 	       aoffset_adj = (a.parm_offset - parm_offset)
 			     << LOG2_BITS_PER_UNIT;
@@ -618,6 +621,7 @@ private:
 	    found = true;
 	  if (!found && n->merge (*a, false))
 	    found = restart = true;
+	  gcc_checking_assert (found || !a->merge (*n, false));
 	  if (found)
 	    {
 	      accesses->unordered_remove (i);
diff --git a/gcc/testsuite/g++.dg/torture/pr102581.C b/gcc/testsuite/g++.dg/torture/pr102581.C
new file mode 100644
index 00000000000..7f172d088b8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr102581.C
@@ -0,0 +1,51 @@
+// { dg-do compile }
+/* { dg-additional-options "-fno-strict-aliasing" } */
+enum VkStructureType {
+  VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT,
+  VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR
+} typedef VkPhysicalDeviceSparseProperties;
+struct VkPhysicalDeviceProperties {
+  int apiVersion;
+  VkPhysicalDeviceSparseProperties sparseProperties;
+};
+typedef struct {
+  VkStructureType sType;
+  int *pPhysicalDevices;
+} VkPhysicalDeviceFeatures2;
+typedef struct VkPhysicalDeviceProperties2 {
+  VkStructureType sType;
+  void *pNext;
+} VkPhysicalDeviceMemoryProperties2;
+struct VulkanVersion {
+  int major;
+  int minor;
+  int patch;
+};
+int make_vulkan_version_version;
+VulkanVersion make_vulkan_version() {
+  return {make_vulkan_version_version, make_vulkan_version_version,
+          make_vulkan_version_version};
+}
+struct AppGpu {
+  int &inst;
+  int id;
+  int *phys_device = nullptr;
+  VulkanVersion api_version{};
+  VkPhysicalDeviceProperties props{};
+  VkPhysicalDeviceProperties2 props2{};
+  int memory_props{};
+  VkPhysicalDeviceMemoryProperties2 memory_props2{};
+  int features{};
+  VkPhysicalDeviceFeatures2 features2{};
+  int *dev = nullptr;
+  int enabled_features{};
+  int AppGpu_phys_device;
+  int AppGpu_inst;
+  AppGpu() : inst(AppGpu_inst), id() {
+    api_version = make_vulkan_version();
+    props2.sType = memory_props2.sType = features2.sType =
+        VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR;
+  }
+};
+int
+main() { AppGpu(); return 0; }


                 reply	other threads:[~2021-10-07 13:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211007132623.305533858426@sourceware.org \
    --to=hubicka@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).