From patchwork Thu Sep 22 07:21:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Rosen X-Patchwork-Id: 4244 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 7C10E23EF6 for ; Thu, 22 Sep 2011 07:21:32 +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 580D0A18387 for ; Thu, 22 Sep 2011 07:21:32 +0000 (UTC) Received: by fxe23 with SMTP id 23so3475624fxe.11 for ; Thu, 22 Sep 2011 00:21:32 -0700 (PDT) Received: by 10.223.55.136 with SMTP id u8mr2585879fag.46.1316676092156; Thu, 22 Sep 2011 00:21:32 -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.18.198 with SMTP id y6cs158346lad; Thu, 22 Sep 2011 00:21:31 -0700 (PDT) Received: by 10.236.79.72 with SMTP id h48mr11569954yhe.4.1316676090867; Thu, 22 Sep 2011 00:21:30 -0700 (PDT) Received: from mail-yx0-f178.google.com (mail-yx0-f178.google.com [209.85.213.178]) by mx.google.com with ESMTPS id j69si1190395yhn.122.2011.09.22.00.21.30 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 22 Sep 2011 00:21:30 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.213.178 is neither permitted nor denied by best guess record for domain of ira.rosen@linaro.org) client-ip=209.85.213.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.213.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 yxj19 with SMTP id 19so3103617yxj.37 for ; Thu, 22 Sep 2011 00:21:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.150.2.16 with SMTP id 16mr1949997ybb.333.1316676090117; Thu, 22 Sep 2011 00:21:30 -0700 (PDT) Received: by 10.151.100.9 with HTTP; Thu, 22 Sep 2011 00:21:29 -0700 (PDT) Date: Thu, 22 Sep 2011 10:21:29 +0300 Message-ID: Subject: [patch] Fix PR tree-optimization/50451 From: Ira Rosen To: gcc-patches@gcc.gnu.org Cc: Patch Tracking Hi, This patch adds a missing support of constant operands in reduction in SLP. Bootstrapped and tested on powerpc64-suse-linux. Committed. Ira ChangeLog: PR tree-optimization/50451 * tree-vect-slp.c (vect_get_constant_vectors): Don't fail for constant operands in reduction. (vect_get_slp_defs): Don't create vector operand for NULL scalar operand. testsuite/ChangeLog: PR tree-optimization/50451 * gcc.dg/vect/pr50451.c: New test. Index: tree-vect-slp.c =================================================================== --- tree-vect-slp.c (revision 179076) +++ tree-vect-slp.c (working copy) @@ -1905,14 +1905,9 @@ vect_get_constant_vectors (tree op, slp_tree slp_n gimple def_stmt; struct loop *loop; - if (STMT_VINFO_DEF_TYPE (stmt_vinfo) == vect_reduction_def) + if (STMT_VINFO_DEF_TYPE (stmt_vinfo) == vect_reduction_def + && reduc_index != -1) { - if (reduc_index == -1) - { - VEC_free (tree, heap, *vec_oprnds); - return; - } - op_num = reduc_index - 1; op = gimple_op (stmt, reduc_index); /* For additional copies (see the explanation of NUMBER_OF_COPIES below) @@ -2164,7 +2159,7 @@ vect_get_slp_defs (tree op0, tree op1, slp_tree sl return; code = gimple_assign_rhs_code (first_stmt); - if (get_gimple_rhs_class (code) != GIMPLE_BINARY_RHS || !vec_oprnds1) + if (get_gimple_rhs_class (code) != GIMPLE_BINARY_RHS || !vec_oprnds1 || !op1) return; /* The number of vector defs is determined by the number of vector statements Index: testsuite/gcc.dg/vect/pr50451.c =================================================================== --- testsuite/gcc.dg/vect/pr50451.c (revision 0) +++ testsuite/gcc.dg/vect/pr50451.c (revision 0) @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +int +foo (int integral, int decimal, int power_ten) +{ + while (power_ten > 0) + { + integral *= 10; + decimal *= 10; + power_ten--; + } + + return integral+decimal; +} + +/* { dg-final { cleanup-tree-dump "vect" } } */ +