From patchwork Wed Jul 20 09:24:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 650604 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rvWhH2xfnz9t10 for ; Wed, 20 Jul 2016 19:24:29 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=dAyRJODJ; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=vsrIadagbZ9vtgbWrNXfWnIEZmkUlBQEGlg+09eVYk9txSu5G9 iD+DX6FLGvGJH2fWiDd6EFKvTcUP2MOhTfTjIxZRmPwsb7jrN8Qu7eT5kPdK/1ZD q9MERDO4/JwscgqwIXPYAR8AxOwhhjPZ8a1CZHv8a613Kt+i8lnn1ypHc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=bvh8MES+JZjOMi38iAB8sPYl1MY=; b=dAyRJODJAqXOBtq9BKcx NmDDMrQKv0GOwP79iudiAp0TgEEaAZe4ZIbyDVWqOoiHllcuKlZsvFAOTY/GWj7C HcixDuWJ8AxuYDnfQs0tI/yoxm9Olmq8F4go/RWIUIRKNPUAQdWTMZAcrUtCjgPB xqNafJcaA3oSsS3ev7bJQ9c= Received: (qmail 68207 invoked by alias); 20 Jul 2016 09:24:23 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 68190 invoked by uid 89); 20 Jul 2016 09:24:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, SPF_PASS autolearn=ham version=3.3.2 spammy=2016-07-20 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Wed, 20 Jul 2016 09:24:11 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 8A520AAAD for ; Wed, 20 Jul 2016 09:24:07 +0000 (UTC) To: GCC Patches From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Subject: [PATCH] Properly handly PHI stmts in later_of_the_two (PR, middle-end/71898) Message-ID: <6b1516cc-d79d-4d51-f066-62c03747f273@suse.cz> Date: Wed, 20 Jul 2016 11:24:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 X-IsSubscribed: yes Hi. Graphite uses comparison of gsi_stmt_iterators (later_of_the_two) to find a place where to insert a new gimple statement. Problem of the function is that it does not distinguish between PHI and non-PHI statements, where the former one always stands before the later one. The patch fixes that. Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. Ready to be installed? Martin From 0ce169ea9201ca63f335404bb86a48ea98c11299 Mon Sep 17 00:00:00 2001 From: marxin Date: Wed, 20 Jul 2016 09:13:40 +0200 Subject: [PATCH] Properly handly PHI stmts in later_of_the_two (PR middle-end/71898) gcc/ChangeLog: 2016-07-20 Martin Liska PR middle-end/71898 * graphite-isl-ast-to-gimple.c (later_of_the_two): Properly handly PHI stmts. gcc/testsuite/ChangeLog: 2016-07-20 Martin Liska * gfortran.dg/graphite/pr71898.f90: New test. --- gcc/graphite-isl-ast-to-gimple.c | 12 +++++++ gcc/testsuite/gfortran.dg/graphite/pr71898.f90 | 45 ++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/graphite/pr71898.f90 diff --git a/gcc/graphite-isl-ast-to-gimple.c b/gcc/graphite-isl-ast-to-gimple.c index fb9c846..07c88026 100644 --- a/gcc/graphite-isl-ast-to-gimple.c +++ b/gcc/graphite-isl-ast-to-gimple.c @@ -1305,6 +1305,18 @@ later_of_the_two (gimple_stmt_iterator gsi1, gimple_stmt_iterator gsi2) /* Find the iterator which is the latest. */ if (bb1 == bb2) { + gimple *stmt1 = gsi_stmt (gsi1); + gimple *stmt2 = gsi_stmt (gsi2); + + if (stmt1 != NULL && stmt2 != NULL) + { + bool is_phi1 = gimple_code (stmt1) == GIMPLE_PHI; + bool is_phi2 = gimple_code (stmt2) == GIMPLE_PHI; + + if (is_phi1 != is_phi2) + return is_phi1 ? gsi2 : gsi1; + } + /* For empty basic blocks gsis point to the end of the sequence. Since there is no operator== defined for gimple_stmt_iterator and for gsis not pointing to a valid statement gsi_next would assert. */ diff --git a/gcc/testsuite/gfortran.dg/graphite/pr71898.f90 b/gcc/testsuite/gfortran.dg/graphite/pr71898.f90 new file mode 100644 index 0000000..01d6852 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/graphite/pr71898.f90 @@ -0,0 +1,45 @@ +! { dg-do compile } +! { dg-options "-floop-nest-optimize -O1" } + +MODULE d3_poly + INTEGER, PUBLIC, PARAMETER :: max_grad2=5 + INTEGER, PUBLIC, PARAMETER :: max_grad3=3 + INTEGER, PUBLIC, PARAMETER :: cached_dim2=(max_grad2+1)*(max_grad2+2)/2 + INTEGER, PUBLIC, PARAMETER :: cached_dim3=(max_grad3+1)*(max_grad3+2)*(max_grad3+3)/6 + INTEGER, SAVE, DIMENSION(3,cached_dim3) :: a_mono_exp3 + INTEGER, SAVE, DIMENSION(cached_dim2,cached_dim2) :: a_mono_mult2 + INTEGER, SAVE, DIMENSION(cached_dim3,cached_dim3) :: a_mono_mult3 + INTEGER, SAVE, DIMENSION(4,cached_dim3) :: a_mono_mult3a +CONTAINS +SUBROUTINE init_d3_poly_module() + INTEGER :: grad, i, ii, ij, j, subG + INTEGER, DIMENSION(3) :: monoRes3 + DO grad=0,max_grad2 + DO i=grad,0,-1 + DO j=grad-i,0,-1 + END DO + END DO + END DO + DO ii=1,cached_dim3 + DO ij=ii,cached_dim2 + a_mono_mult2(ij,ii)=a_mono_mult2(ii,ij) + END DO + END DO + DO ii=1,cached_dim3 + DO ij=ii,cached_dim3 + monoRes3=a_mono_exp3(:,ii)+a_mono_exp3(:,ij) + a_mono_mult3(ii,ij)=mono_index3(monoRes3(1),monoRes3(2),monoRes3(3))+1 + a_mono_mult3(ij,ii)=a_mono_mult3(ii,ij) + END DO + END DO + DO i=1,cached_dim3 + DO j=1,4 + a_mono_mult3a(j,i)=a_mono_mult3(j,i) + END DO + END DO +END SUBROUTINE +PURE FUNCTION mono_index3(i,j,k) RESULT(res) + INTEGER, INTENT(in) :: i, j, k + res=grad*(grad+1)*(grad+2)/6+(sgrad)*(sgrad+1)/2+k +END FUNCTION +END MODULE d3_poly -- 2.9.0