public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch  PR 45260]:  [4.5/4.6 Regression] g++4.5: -prefetch-loop-arrays internal compiler error: in verify_expr, at tree-cfg.c:2541
@ 2010-08-20 23:18 Fang, Changpeng
  2010-08-23 16:39 ` Richard Guenther
  0 siblings, 1 reply; 2+ messages in thread
From: Fang, Changpeng @ 2010-08-20 23:18 UTC (permalink / raw)
  To: gcc-patches; +Cc: rguenther, pinskia, Zdenek Dvorak, sebpop

[-- Attachment #1: Type: text/plain, Size: 762 bytes --]

Hi,

The attached patch fixes PR 45260:  [4.5/4.6 Regression] g++4.5: -prefetch-loop-arrays internal compiler error: in verify_expr, at tree-cfg.c:2541

Problem: The prefetch pass generates an ADDR_EXPR for COMPONENT_REF(VIEW_CONVERT_EXPR(SSA_NAME)) whose
address could not be taken, and thus invokes an assertion failure in verify_expr.

Solution: Don't generate prefetch for references whose base address could not be taken.

In this patch, we make may_be_nonaddressable_p (tree expr) global and use it in the prefetch pass.

This patch passed bootstrapping and gcc regression tests on x86_64-unknown-linux-gnu systems ib both
trunk and 4.5 branch.

Is it OK to commit to trunk and 4.5 branch?

Thanks and have a wonderful weekend!

Changpeng

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-pr45260-Don-t-generate-prefetch-if-the-address-of-ba.patch --]
[-- Type: text/x-patch; name="0001-pr45260-Don-t-generate-prefetch-if-the-address-of-ba.patch", Size: 2260 bytes --]

From ac383eec351bab858f0be30b4a89947a566853e2 Mon Sep 17 00:00:00 2001
From: Changpeng Fang <chfang@houghton.(none)>
Date: Fri, 20 Aug 2010 12:10:43 -0700
Subject: [PATCH] pr45260 Don't generate prefetch if the address of base could not be taken.

	* tree-flow.h (may_be_nonaddressable_p): New definition. Make the
	existing static function global.

	*tree-ssa-loop-ivopts.c (may_be_nonaddressable_p): This function
	is changed to global.

	*tree-ssa-loop-prefetch.c (gather_memory_references_ref): Call
	may_be_nonaddressable_p on base, and don't collect this reference
	if the address of the base could not be taken.
---
 gcc/tree-flow.h              |    1 +
 gcc/tree-ssa-loop-ivopts.c   |    2 +-
 gcc/tree-ssa-loop-prefetch.c |    4 ++++
 3 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h
index 04ba532..6731308 100644
--- a/gcc/tree-flow.h
+++ b/gcc/tree-flow.h
@@ -817,6 +817,7 @@ bool stmt_invariant_in_loop_p (struct loop *, gimple);
 bool multiplier_allowed_in_address_p (HOST_WIDE_INT, enum machine_mode,
 				      addr_space_t);
 unsigned multiply_by_cost (HOST_WIDE_INT, enum machine_mode, bool);
+bool may_be_nonaddressable_p (tree expr);
 
 /* In tree-ssa-threadupdate.c.  */
 extern bool thread_through_all_blocks (bool);
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index a347c86..0029c76 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -1640,7 +1640,7 @@ may_be_unaligned_p (tree ref, tree step)
 
 /* Return true if EXPR may be non-addressable.   */
 
-static bool
+bool
 may_be_nonaddressable_p (tree expr)
 {
   switch (TREE_CODE (expr))
diff --git a/gcc/tree-ssa-loop-prefetch.c b/gcc/tree-ssa-loop-prefetch.c
index 9ad6cd2..4e7068f 100644
--- a/gcc/tree-ssa-loop-prefetch.c
+++ b/gcc/tree-ssa-loop-prefetch.c
@@ -539,6 +539,10 @@ gather_memory_references_ref (struct loop *loop, struct mem_ref_group **refs,
   if (step == NULL_TREE)
     return false;
 
+  /* Stop if the address of BASE could not taken.  */
+  if (may_be_nonaddressable_p (base))
+    return false;
+
   /* Limit non-constant step prefetching only to the innermost loops.  */
   if (!cst_and_fits_in_hwi (step) && loop->inner != NULL)
     return false;
-- 
1.6.3.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-08-23 16:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-20 23:18 [Patch PR 45260]: [4.5/4.6 Regression] g++4.5: -prefetch-loop-arrays internal compiler error: in verify_expr, at tree-cfg.c:2541 Fang, Changpeng
2010-08-23 16:39 ` Richard Guenther

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).