[11/12] ipa-sra: Make scan_expr_access bail out on uninteresting expressions

Message ID ri6h6z5kkoy.fsf@suse.cz
State Accepted
Headers
Series [01/12] ipa: IPA-SRA split detection simplification |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Martin Jambor Nov. 12, 2022, 1:47 a.m. UTC
  Hi,

I have noticed that scan_expr_access passes all the expressions it
gets to get_ref_base_and_extent even when we are really only
interested in memory accesses.  So bail out when the expression is
something clearly uninteresting.

Bootstrapped and tested on x86_64-linux.  OK for master?

Thanks,

Martin


gcc/ChangeLog:

2021-12-14  Martin Jambor  <mjambor@suse.cz>

	* ipa-sra.c (scan_expr_access): Bail out early if expr is something we
	clearly do not need to pass to get_ref_base_and_extent.
---
 gcc/ipa-sra.cc | 5 +++++
 1 file changed, 5 insertions(+)
  

Patch

diff --git a/gcc/ipa-sra.cc b/gcc/ipa-sra.cc
index 93fceeafc73..3646d71468c 100644
--- a/gcc/ipa-sra.cc
+++ b/gcc/ipa-sra.cc
@@ -1748,6 +1748,11 @@  scan_expr_access (tree expr, gimple *stmt, isra_scan_context ctx,
       || TREE_CODE (expr) == REALPART_EXPR)
     expr = TREE_OPERAND (expr, 0);
 
+  if (!handled_component_p (expr)
+      && !DECL_P (expr)
+      && TREE_CODE (expr) != MEM_REF)
+    return;
+
   base = get_ref_base_and_extent (expr, &poffset, &psize, &pmax_size, &reverse);
 
   if (TREE_CODE (base) == MEM_REF)