From patchwork Thu Sep 1 08:12:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Rosen X-Patchwork-Id: 3822 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id BD1F523F36 for ; Thu, 1 Sep 2011 08:12:21 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id A8962A18065 for ; Thu, 1 Sep 2011 08:12:21 +0000 (UTC) Received: by fxd18 with SMTP id 18so679906fxd.11 for ; Thu, 01 Sep 2011 01:12:21 -0700 (PDT) Received: by 10.223.88.214 with SMTP id b22mr1330660fam.5.1314864741474; Thu, 01 Sep 2011 01:12:21 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.11.8 with SMTP id m8cs43861lab; Thu, 1 Sep 2011 01:12:21 -0700 (PDT) Received: by 10.150.209.9 with SMTP id h9mr1042566ybg.308.1314864739939; Thu, 01 Sep 2011 01:12:19 -0700 (PDT) Received: from mail-gw0-f50.google.com (mail-gw0-f50.google.com [74.125.83.50]) by mx.google.com with ESMTPS id v2si537693ybl.53.2011.09.01.01.12.19 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 01 Sep 2011 01:12:19 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.50 is neither permitted nor denied by best guess record for domain of ira.rosen@linaro.org) client-ip=74.125.83.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.83.50 is neither permitted nor denied by best guess record for domain of ira.rosen@linaro.org) smtp.mail=ira.rosen@linaro.org Received: by gwj16 with SMTP id 16so821547gwj.37 for ; Thu, 01 Sep 2011 01:12:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.117.1 with SMTP id p1mr1060141anc.129.1314864739040; Thu, 01 Sep 2011 01:12:19 -0700 (PDT) Received: by 10.100.191.10 with HTTP; Thu, 1 Sep 2011 01:12:18 -0700 (PDT) Date: Thu, 1 Sep 2011 11:12:18 +0300 Message-ID: Subject: [patch] Fix PR tree-optimization/50178 From: Ira Rosen To: gcc-patches@gcc.gnu.org Cc: Patch Tracking Hi, When vectorizing a function call we replace the original call with a dummy statement to ensure that DCE later removes it. We also remove its stmt_vec_info, which causes the segfault when we try to access it through related pattern stmt. The following patch updates related pattern stmt to be the dummy stmt. Bootstrapped and tested on powerpc64-suse-linux. OK for 4.6? Thanks, Ira ChangeLog: PR tree-optimization/50178 * tree-vect-stmts.c (vectorizable_call): Update the related pattern statement before deleting the original call. (vect_transform_stmt): Don't expect the related pattern statement match the original statement after transformation. testsuite/ChangeLog: PR tree-optimization/50178 * gfortran.dg/vect/pr50178.f90: New test. Index: testsuite/gfortran.dg/vect/pr50178.f90 =================================================================== --- testsuite/gfortran.dg/vect/pr50178.f90 (revision 0) +++ testsuite/gfortran.dg/vect/pr50178.f90 (revision 0) @@ -0,0 +1,29 @@ +! { dg-do compile } + +module yemdyn + implicit none + integer, parameter :: jpim = selected_int_kind(9) + integer, parameter :: jprb = selected_real_kind(13,300) + real(kind=jprb) :: elx + real(kind=jprb), allocatable :: xkcoef(:) + integer(kind=jpim),allocatable :: ncpln(:), npne(:) +end module yemdyn + +subroutine suedyn + + use yemdyn + + implicit none + + integer(kind=jpim) :: jm, jn + real(kind=jprb) :: zjm, zjn, zxxx + + jn=0 + do jm=0,ncpln(jn) + zjm=real(jm,jprb) / elx + xkcoef(npne(jn)+jm) = - zxxx*(zjm**2)**0.5_jprb + end do + +end subroutine suedyn + +! { dg-final { cleanup-tree-dump "vect" } } Index: tree-vect-stmts.c =================================================================== --- tree-vect-stmts.c (revision 178373) +++ tree-vect-stmts.c (working copy) @@ -1583,6 +1583,14 @@ vectorizable_call (gimple stmt, gimple_stmt_iterat new_stmt = gimple_build_assign (gimple_call_lhs (stmt), build_zero_cst (type)); set_vinfo_for_stmt (new_stmt, stmt_info); + /* For pattern statements make the related statement to point to + NEW_STMT in order to be able to retrieve the original statement + information later. */ + if (is_pattern_stmt_p (stmt_info)) + { + gimple related = STMT_VINFO_RELATED_STMT (stmt_info); + STMT_VINFO_RELATED_STMT (vinfo_for_stmt (related)) = new_stmt; + } set_vinfo_for_stmt (stmt, NULL); STMT_VINFO_STMT (stmt_info) = new_stmt; gsi_replace (gsi, new_stmt, false); @@ -4957,11 +4965,7 @@ vect_transform_stmt (gimple stmt, gimple_stmt_iter the stmt_info of ORIG_STMT_IN_PATTERN. See more details in the documentation of vect_pattern_recog. */ if (STMT_VINFO_IN_PATTERN_P (stmt_vinfo)) - { - gcc_assert (STMT_VINFO_RELATED_STMT (stmt_vinfo) - == orig_scalar_stmt); - STMT_VINFO_VEC_STMT (stmt_vinfo) = vec_stmt; - } + STMT_VINFO_VEC_STMT (stmt_vinfo) = vec_stmt; } }