diff mbox

[PR44955] : Strip off the real and imagine part in gathering memory references for prefetching

Message ID D4C76825A6780047854A11E93CDE84D00A678CF8@SAUSEXMBP01.amd.com
State New
Headers show

Commit Message

Fang, Changpeng July 20, 2010, 9:02 p.m. UTC
Hi,

Attached is a patch that fixes bug 44955: over-prefetched for array of complex numbers.

Current prefetch pass inserts prefetches for the real part and imagine part of a complex array
separately, and thus over-prefetched. The reason is that they have different bases and go to
different groups, and reuse analysis could not be performed across groups.

The attached patch strip off the REALPART_EXPR and IMAGPART_EXPR with an adjustment
of the offset for the IMAGPART_EXPR. As a result, the related two references could have the same
base and fall into the same group. For the test case in bug 44955, prefetches are generated only
for the real parts after applying the patch.

Ptached passed bootstrapping.

Is it OK for the trunk?

Thanks,

Changpeng

Comments

Zdenek Dvorak July 21, 2010, 6:44 a.m. UTC | #1
Hi,

> Attached is a patch that fixes bug 44955: over-prefetched for array of complex numbers.
> 
> Current prefetch pass inserts prefetches for the real part and imagine part of a complex array
> separately, and thus over-prefetched. The reason is that they have different bases and go to
> different groups, and reuse analysis could not be performed across groups.
> 
> The attached patch strip off the REALPART_EXPR and IMAGPART_EXPR with an adjustment
> of the offset for the IMAGPART_EXPR. As a result, the related two references could have the same
> base and fall into the same group. For the test case in bug 44955, prefetches are generated only
> for the real parts after applying the patch.
> 
> Ptached passed bootstrapping.
> 
> Is it OK for the trunk?

yes.

Zdenek
Christian Borntraeger July 21, 2010, 8:03 a.m. UTC | #2
Am Dienstag 20 Juli 2010, 23:02:19 schrieb Fang, Changpeng:
> Hi,
> 
> Attached is a patch that fixes bug 44955: over-prefetched for array of complex numbers.
> 
> Current prefetch pass inserts prefetches for the real part and imagine part of a complex array
> separately, and thus over-prefetched. The reason is that they have different bases and go to
> different groups, and reuse analysis could not be performed across groups.
> 
> The attached patch strip off the REALPART_EXPR and IMAGPART_EXPR with an adjustment
> of the offset for the IMAGPART_EXPR. As a result, the related two references could have the same
> base and fall into the same group. For the test case in bug 44955, prefetches are generated only
> for the real parts after applying the patch.
> 
> Ptached passed bootstrapping.

Works also fine on s390.
Sebastian Pop July 21, 2010, 3:45 p.m. UTC | #3
On Wed, Jul 21, 2010 at 01:44, Zdenek Dvorak <rakdver@kam.mff.cuni.cz> wrote:
> Hi,
>
>> Attached is a patch that fixes bug 44955: over-prefetched for array of complex numbers.
>>
>> Current prefetch pass inserts prefetches for the real part and imagine part of a complex array
>> separately, and thus over-prefetched. The reason is that they have different bases and go to
>> different groups, and reuse analysis could not be performed across groups.
>>
>> The attached patch strip off the REALPART_EXPR and IMAGPART_EXPR with an adjustment
>> of the offset for the IMAGPART_EXPR. As a result, the related two references could have the same
>> base and fall into the same group. For the test case in bug 44955, prefetches are generated only
>> for the real parts after applying the patch.
>>
>> Ptached passed bootstrapping.
>>
>> Is it OK for the trunk?
>
> yes.

Committed r162381.
diff mbox

Patch

From a31b7163ba994357f66ec4fa258290d183441ee7 Mon Sep 17 00:00:00 2001
From: Changpeng Fang <chfang@pathscale.(none)>
Date: Mon, 19 Jul 2010 15:00:15 -0700
Subject: [PATCH 3/3] PR 44955: Strip off the real and complex parts

	* tree-ssa-loop-prefetch.c (analyze_ref): Strip off the real
	and imagine parts of a complex, so that they can have the same
	base and fall into the same group.
---
 gcc/tree-ssa-loop-prefetch.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/gcc/tree-ssa-loop-prefetch.c b/gcc/tree-ssa-loop-prefetch.c
index ded4672..5d53476 100644
--- a/gcc/tree-ssa-loop-prefetch.c
+++ b/gcc/tree-ssa-loop-prefetch.c
@@ -481,10 +481,18 @@  analyze_ref (struct loop *loop, tree *ref_p, tree *base,
   *step = NULL_TREE;
   *delta = 0;
 
-  /* First strip off the component references.  Ignore bitfields.  */
-  if (TREE_CODE (ref) == COMPONENT_REF
-      && DECL_NONADDRESSABLE_P (TREE_OPERAND (ref, 1)))
-    ref = TREE_OPERAND (ref, 0);
+  /* First strip off the component references.  Ignore bitfields.
+     Also strip off the real and imagine parts of a complex, so that
+     they can have the same base.  */
+  if (TREE_CODE (ref) == REALPART_EXPR
+      || TREE_CODE (ref) == IMAGPART_EXPR
+      || (TREE_CODE (ref) == COMPONENT_REF
+          && DECL_NONADDRESSABLE_P (TREE_OPERAND (ref, 1))))
+    {
+      if (TREE_CODE (ref) == IMAGPART_EXPR)
+        *delta += int_size_in_bytes (TREE_TYPE (ref));
+      ref = TREE_OPERAND (ref, 0);
+    }
 
   *ref_p = ref;
 
-- 
1.6.3.3