From patchwork Tue Aug 9 06:02:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Rosen X-Patchwork-Id: 3306 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 B0451241D9 for ; Tue, 9 Aug 2011 06:03:00 +0000 (UTC) Received: from mail-qy0-f180.google.com (mail-qy0-f180.google.com [209.85.216.180]) by fiordland.canonical.com (Postfix) with ESMTP id 70E5CA1802D for ; Tue, 9 Aug 2011 06:03:00 +0000 (UTC) Received: by qyk31 with SMTP id 31so3128281qyk.11 for ; Mon, 08 Aug 2011 23:03:00 -0700 (PDT) Received: by 10.224.209.9 with SMTP id ge9mr4886442qab.19.1312869779679; Mon, 08 Aug 2011 23:02:59 -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.229.190.71 with SMTP id dh7cs36383qcb; Mon, 8 Aug 2011 23:02:58 -0700 (PDT) Received: from mr.google.com ([10.236.181.74]) by 10.236.181.74 with SMTP id k50mr1399194yhm.208.1312869778714 (num_hops = 1); Mon, 08 Aug 2011 23:02:58 -0700 (PDT) Received: by 10.236.181.74 with SMTP id k50mr1018091yhm.208.1312869778118; Mon, 08 Aug 2011 23:02:58 -0700 (PDT) Received: from mail-yw0-f50.google.com (mail-yw0-f50.google.com [209.85.213.50]) by mx.google.com with ESMTPS id r26si5467182yhm.142.2011.08.08.23.02.56 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 08 Aug 2011 23:02:57 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.213.50 is neither permitted nor denied by best guess record for domain of ira.rosen@linaro.org) client-ip=209.85.213.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.213.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 ywa12 with SMTP id 12so3578831ywa.37 for ; Mon, 08 Aug 2011 23:02:56 -0700 (PDT) MIME-Version: 1.0 Received: by 10.101.144.18 with SMTP id w18mr1584739ann.133.1312869776697; Mon, 08 Aug 2011 23:02:56 -0700 (PDT) Received: by 10.100.207.7 with HTTP; Mon, 8 Aug 2011 23:02:56 -0700 (PDT) Date: Tue, 9 Aug 2011 09:02:56 +0300 Message-ID: Subject: [patch] Fix PR tree-optimization/50014 From: Ira Rosen To: gcc-patches@gcc.gnu.org Cc: Patch Tracking Hi, In vectorization of reduction we use a dummy def_type when getting a copy of a vector operand. Therefore, instead of just using a constant operand from a previous copy, we try to create a copy of it, causing the failure. This patch adds a call to vect_is_simple_use () to get a correct def_type. Bootstrapped and tested on powerpc64-suse-linux. Committed. Ira ChangeLog: PR tree-optimization/50014 * tree-vect-loop.c (vectorizable_reduction): Get def type before calling vect_get_vec_def_for_stmt_copy (). testsuite/ChangeLog: PR tree-optimization/50014 * gcc.dg/vect/pr50014.c: New test. Index: tree-vect-loop.c =================================================================== --- tree-vect-loop.c (revision 177580) +++ tree-vect-loop.c (working copy) @@ -4318,7 +4318,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i VEC (tree, heap) *vec_oprnds0 = NULL, *vec_oprnds1 = NULL, *vect_defs = NULL; VEC (gimple, heap) *phis = NULL; int vec_num; - tree def0, def1, tem; + tree def0, def1, tem, op0, op1 = NULL_TREE; /* In case of reduction chain we switch to the first stmt in the chain, but we don't update STMT_INFO, since only the last stmt is marked as reduction @@ -4775,8 +4775,6 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i /* Handle uses. */ if (j == 0) { - tree op0, op1 = NULL_TREE; - op0 = ops[!reduc_index]; if (op_type == ternary_op) { @@ -4806,11 +4804,19 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i { if (!slp_node) { - enum vect_def_type dt = vect_unknown_def_type; /* Dummy */ - loop_vec_def0 = vect_get_vec_def_for_stmt_copy (dt, loop_vec_def0); + enum vect_def_type dt; + gimple dummy_stmt; + tree dummy; + + vect_is_simple_use (ops[!reduc_index], loop_vinfo, NULL, + &dummy_stmt, &dummy, &dt); + loop_vec_def0 = vect_get_vec_def_for_stmt_copy (dt, + loop_vec_def0); VEC_replace (tree, vec_oprnds0, 0, loop_vec_def0); if (op_type == ternary_op) { + vect_is_simple_use (op1, loop_vinfo, NULL, &dummy_stmt, + &dummy, &dt); loop_vec_def1 = vect_get_vec_def_for_stmt_copy (dt, loop_vec_def1); VEC_replace (tree, vec_oprnds1, 0, loop_vec_def1); Index: testsuite/gcc.dg/vect/pr50014.c =================================================================== --- testsuite/gcc.dg/vect/pr50014.c (revision 0) +++ testsuite/gcc.dg/vect/pr50014.c (revision 0) @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +int f(unsigned char *s, int n) +{ + int sum = 0; + int i; + + for (i = 0; i < n; i++) + sum += 256 * s[i]; + + return sum; +} + +/* { dg-final { cleanup-tree-dump "vect" } } */ +