From patchwork Thu Nov 10 10:14:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Rosen X-Patchwork-Id: 5025 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 5BD7A23E10 for ; Thu, 10 Nov 2011 10:14:38 +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 44AAEA18256 for ; Thu, 10 Nov 2011 10:14:38 +0000 (UTC) Received: by faan26 with SMTP id n26so3748818faa.11 for ; Thu, 10 Nov 2011 02:14:38 -0800 (PST) Received: by 10.152.109.199 with SMTP id hu7mr4171081lab.16.1320920077935; Thu, 10 Nov 2011 02:14:37 -0800 (PST) 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.3.196 with SMTP id e4cs63lae; Thu, 10 Nov 2011 02:14:37 -0800 (PST) Received: by 10.224.199.134 with SMTP id es6mr5082729qab.2.1320920074885; Thu, 10 Nov 2011 02:14:34 -0800 (PST) Received: from mail-qy0-f178.google.com (mail-qy0-f178.google.com [209.85.216.178]) by mx.google.com with ESMTPS id ge5si4780977qab.73.2011.11.10.02.14.33 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 10 Nov 2011 02:14:34 -0800 (PST) Received-SPF: neutral (google.com: 209.85.216.178 is neither permitted nor denied by best guess record for domain of ira.rosen@linaro.org) client-ip=209.85.216.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.216.178 is neither permitted nor denied by best guess record for domain of ira.rosen@linaro.org) smtp.mail=ira.rosen@linaro.org Received: by qyg14 with SMTP id 14so3155230qyg.16 for ; Thu, 10 Nov 2011 02:14:33 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.111.8 with SMTP id ie8mr1691036obb.50.1320920073609; Thu, 10 Nov 2011 02:14:33 -0800 (PST) Received: by 10.182.183.102 with HTTP; Thu, 10 Nov 2011 02:14:33 -0800 (PST) Date: Thu, 10 Nov 2011 12:14:33 +0200 Message-ID: Subject: [patch] Fix PR tree-optimization/51058 From: Ira Rosen To: gcc-patches@gcc.gnu.org Cc: Patch Tracking Hi, This patch handles CALL_EXPRs in constant/invariant operand creation in SLP. Bootstrapped and tested on powerpc64-suse-linux. Committed. Ira ChangeLog: PR tree-optimization/51058 * tree-vect-slp.c (vect_get_constant_vectors): Handle CALL_EXPR. testsuite/ChangeLog: PR tree-optimization/51058 * gfortran.dg/vect/pr51058.f90: New test. Index: tree-vect-slp.c =================================================================== --- tree-vect-slp.c (revision 181250) +++ tree-vect-slp.c (working copy) @@ -2191,7 +2191,7 @@ vect_get_constant_vectors (tree op, slp_tree slp_n VEC (tree, heap) *voprnds = VEC_alloc (tree, heap, number_of_vectors); bool constant_p, is_store; tree neutral_op = NULL; - enum tree_code code = gimple_assign_rhs_code (stmt); + enum tree_code code = gimple_expr_code (stmt); gimple def_stmt; struct loop *loop; @@ -2287,22 +2287,32 @@ vect_get_constant_vectors (tree op, slp_tree slp_n { if (is_store) op = gimple_assign_rhs1 (stmt); - else if (gimple_assign_rhs_code (stmt) != COND_EXPR) - op = gimple_op (stmt, op_num + 1); - else + else { - if (op_num == 0 || op_num == 1) + switch (code) { - tree cond = gimple_assign_rhs1 (stmt); - op = TREE_OPERAND (cond, op_num); + case COND_EXPR: + if (op_num == 0 || op_num == 1) + { + tree cond = gimple_assign_rhs1 (stmt); + op = TREE_OPERAND (cond, op_num); + } + else + { + if (op_num == 2) + op = gimple_assign_rhs2 (stmt); + else + op = gimple_assign_rhs3 (stmt); + } + break; + + case CALL_EXPR: + op = gimple_call_arg (stmt, op_num); + break; + + default: + op = gimple_op (stmt, op_num + 1); } - else - { - if (op_num == 2) - op = gimple_assign_rhs2 (stmt); - else - op = gimple_assign_rhs3 (stmt); - } } if (reduc_index != -1) Index: testsuite/gfortran.dg/vect/pr51058.f90 =================================================================== --- testsuite/gfortran.dg/vect/pr51058.f90 (revision 0) +++ testsuite/gfortran.dg/vect/pr51058.f90 (revision 0) @@ -0,0 +1,19 @@ +! { dg-do compile } + + SUBROUTINE MLIST(MOLsp,PBCx,PBCy,PBCz, X0) + IMPLICIT NONE + INTEGER, PARAMETER :: NM=16384 + INTEGER :: MOLsp, i + REAL :: PBCx, PBCy, PBCz, boxjmp, HALf=1./2. + REAL :: X0(2,-2:NM) + + DO i = 1 , MOLsp + boxjmp = PBCx*INT(X0(1,i)+SIGN(HALf,X0(1,i))) + X0(1,i) = X0(1,i) - boxjmp + boxjmp = PBCy*INT(X0(2,i)+SIGN(HALf,X0(2,i))) + X0(2,i) = X0(2,i) - boxjmp + ENDDO + END + +! { dg-final { cleanup-tree-dump "vect" } } +