From patchwork Mon Oct 11 12:19:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Rosen X-Patchwork-Id: 67415 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]) by ozlabs.org (Postfix) with SMTP id 8F34FB6EE9 for ; Mon, 11 Oct 2010 23:20:13 +1100 (EST) Received: (qmail 27540 invoked by alias); 11 Oct 2010 12:20:08 -0000 Received: (qmail 27471 invoked by uid 22791); 11 Oct 2010 12:20:02 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL, BAYES_00, MAY_BE_FORGED, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mtagate2.de.ibm.com (HELO mtagate2.de.ibm.com) (195.212.17.162) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 11 Oct 2010 12:19:53 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate2.de.ibm.com (8.13.1/8.13.1) with ESMTP id o9BCJos2001812 for ; Mon, 11 Oct 2010 12:19:50 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o9BCJoD23854368 for ; Mon, 11 Oct 2010 14:19:50 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o9BCJoPM005231 for ; Mon, 11 Oct 2010 14:19:50 +0200 Received: from d12mc102.megacenter.de.ibm.com (d12nrml1506.megacenter.de.ibm.com [9.149.164.56] (may be forged)) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id o9BCJod1005226 for ; Mon, 11 Oct 2010 14:19:50 +0200 Subject: [patch] Fix PR tree-optimization/45902 X-KeepSent: DAAD5B4A:68EF7EC6-C22577B9:002675D1; type=4; name=$KeepSent To: gcc-patches@gcc.gnu.org Message-ID: From: Ira Rosen Date: Mon, 11 Oct 2010 14:19:48 +0200 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII X-IsSubscribed: yes 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 Hi, This patch fixes a bug in creation of a vector of constants in SLP. The problem is in the type of created vector. It should be set to the vector type of the statement unless it's a pointer. Bootstrapped and tested on x86_64-suse-linux and checked that the failure is fixed on powerpc64-suse-linux. Committed to mainline, ok for 4.5? Thanks, Ira ChangeLog: PR tree-optimization/45902 * tree-vect-slp.c (vect_get_constant_vectors): Use statement's vector type for constants, unless it's a pointer. testsuite/ChangeLog: PR tree-optimization/45902 * gcc.dg/vect/45902.c: New test. 4.6 patch Index: tree-vect-slp.c =================================================================== --- tree-vect-slp.c (revision 164987) +++ tree-vect-slp.c (working copy) @@ -1894,13 +1894,20 @@ vect_get_constant_vectors (slp_tree slp_ } if (CONSTANT_CLASS_P (op)) - constant_p = true; + { + constant_p = true; + if (POINTER_TYPE_P (TREE_TYPE (gimple_assign_lhs (stmt)))) + vector_type = get_vectype_for_scalar_type (TREE_TYPE (op)); + else + vector_type = STMT_VINFO_VECTYPE (stmt_vinfo); + } else - constant_p = false; + { + constant_p = false; + vector_type = get_vectype_for_scalar_type (TREE_TYPE (op)); + } - vector_type = get_vectype_for_scalar_type (TREE_TYPE (op)); gcc_assert (vector_type); - nunits = TYPE_VECTOR_SUBPARTS (vector_type); /* NUMBER_OF_COPIES is the number of times we need to use the same values in Index: testsuite/gcc.dg/vect/pr45902.c =================================================================== --- testsuite/gcc.dg/vect/pr45902.c (revision 0) +++ testsuite/gcc.dg/vect/pr45902.c (revision 0) @@ -0,0 +1,44 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include +#include "tree-vect.h" + +#define N 128 + +short res[N]; +short a[N]; + +int +main1 () +{ + int i; + + for (i = 0; i < N/4; i+=4) + { + res[i] = a[i] >> 8; + res[i+1] = a[i+1] >> 8; + res[i+2] = a[i+2] >> 8; + res[i+3] = a[i+3] >> 8; + } +} + +int +main () +{ + int i; + + for (i = 0; i < N; i++) + a[i] = i; + + main1 (); + + for (i = 0; i < N; i++) + if (res[i] != a[i] >> 8) + abort (); + + return 0; +} + +/* { dg-final { cleanup-tree-dump "vect" } } */ 4.5 patch Index: tree-vect-slp.c =================================================================== --- tree-vect-slp.c (revision 165269) +++ tree-vect-slp.c (working copy) @@ -1459,13 +1459,20 @@ vect_get_constant_vectors (slp_tree slp_ } if (CONSTANT_CLASS_P (op)) - constant_p = true; + { + constant_p = true; + if (POINTER_TYPE_P (TREE_TYPE (gimple_assign_lhs (stmt)))) + vector_type = get_vectype_for_scalar_type (TREE_TYPE (op)); + else + vector_type = STMT_VINFO_VECTYPE (stmt_vinfo); + } else - constant_p = false; + { + constant_p = false; + vector_type = get_vectype_for_scalar_type (TREE_TYPE (op)); + } - vector_type = get_vectype_for_scalar_type (TREE_TYPE (op)); gcc_assert (vector_type); - nunits = TYPE_VECTOR_SUBPARTS (vector_type); /* NUMBER_OF_COPIES is the number of times we need to use the same values in Index: testsuite/gcc.dg/vect/pr45902.c =================================================================== --- testsuite/gcc.dg/vect/pr45902.c (revision 0) +++ testsuite/gcc.dg/vect/pr45902.c (revision 0) @@ -0,0 +1,44 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include +#include "tree-vect.h" + +#define N 128 + +short res[N]; +short a[N]; + +int +main1 () +{ + int i; + + for (i = 0; i < N/4; i+=4) + { + res[i] = a[i] >> 8; + res[i+1] = a[i+1] >> 8; + res[i+2] = a[i+2] >> 8; + res[i+3] = a[i+3] >> 8; + } +} + +int +main () +{ + int i; + + for (i = 0; i < N; i++) + a[i] = i; + + main1 (); + + for (i = 0; i < N; i++) + if (res[i] != a[i] >> 8) + abort (); + + return 0; +} + +/* { dg-final { cleanup-tree-dump "vect" } } */ +