From patchwork Tue Jul 20 21:02:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [PR44955] : Strip off the real and imagine part in gathering memory references for prefetching Date: Tue, 20 Jul 2010 11:02:19 -0000 From: "Fang, Changpeng" X-Patchwork-Id: 59372 Message-Id: To: "Fang, Changpeng" , Christian Borntraeger Cc: Zdenek Dvorak , Richard Guenther , Sebastian Pop , "gcc-patches@gcc.gnu.org" , "uweigand@de.ibm.com" 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 >From a31b7163ba994357f66ec4fa258290d183441ee7 Mon Sep 17 00:00:00 2001 From: Changpeng Fang 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