From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16810 invoked by alias); 31 Jan 2011 18:12:47 -0000 Received: (qmail 16727 invoked by uid 22791); 31 Jan 2011 18:12:46 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 31 Jan 2011 18:12:42 +0000 From: "spop at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/40979] induct benchmark 60% slower when compiled with -fgraphite-identity X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: spop at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: spop at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Mon, 31 Jan 2011 18:53:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-01/txt/msg03429.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40979 --- Comment #11 from Sebastian Pop 2011-01-31 18:12:38 UTC --- Here is a reduced testcase from induct.f90 for the first loop not vectorized with -fgraphite-identity: module mqc_m integer, parameter, private :: longreal = selected_real_kind(15,90) contains subroutine mutual_ind_quad_cir_coil (m, l12) real (kind = longreal), dimension(9), save :: w2gauss, w1gauss real (kind = longreal) :: l12_lower, numerator real (kind = longreal), dimension(3) :: current_vector, coil_current_vec w2gauss(1) = 16.0_longreal/81.0_longreal w1gauss(5) = 0.3302393550_longreal do i = 1, 2*m do j = 1, 9 do k = 1, 9 numerator = w1gauss(j) * w2gauss(k) * & dot_product(coil_current_vec,current_vector) l12_lower = l12_lower + numerator end do end do end do l12 = l12_lower end subroutine mutual_ind_quad_cir_coil end module mqc_m The problem seems to be that graphite introduces a Commutative_Associative_Reduction array that confuses the vectorizer. I looked at how to improve translate_scalar_reduction_to_array in order to avoid the creation of the temporary array, but it seems to be difficult as the result is written to memory under a different type than the reduction itself: l12_lower is a real whereas l12 is an integer: l12_lower_200 = some_computation; # l12_lower_9 = PHI D.1585_43 = (integer(kind=4)) l12_lower_9; # .MEM_48 = VDEF <.MEM_47> *l12_44(D) = D.1585_43; so we cannot use *l12_44(D) as a data reference in the loop to perform the reduction as it does not have the same precision as l12_lower: it seems to me that we cannot avoid creating the temporary array. The solution could be to clean up the temporary arrays after graphite.