From patchwork Sat Mar 29 01:26:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cong Hou X-Patchwork-Id: 334918 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FB441400AF for ; Sat, 29 Mar 2014 12:26:55 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:cc:content-type; q=dns; s=default; b=oddIOytq6dtY74euoi2P3zbndpQUq4/FnDfqV4YpyAh gXXNlWJ8v/G4V45U757oz5jj+YMHR0MVc364CASMkzf7gNf5P8+HxHg2Flgn3sNr m3S1O8vsUv+9YZM0uhfGEUKD7RjEmJvyMU8v/Uwk/BTZFr5LLREUOvDk0MKDRgrA = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:cc:content-type; s=default; bh=B/8FH3Lj2rOiXV90QSlOqJYEMbQ=; b=tSRlpYSnoUFeaZL0p YCHwWkDEm7CYuW/1Iiasnhl/BzKaL5rMcD+kyl8VtbfLDHO8Bns5R6ew0WDedID0 BaMTviMnTVuuxtzcAWDnsq6pqrSbkto9CljDDIk2xjz7E3aEkEygN3RrR9LMuT6T IlhwABq56aD0FphPNtGqRNIKOk= Received: (qmail 7049 invoked by alias); 29 Mar 2014 01:26:48 -0000 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 Received: (qmail 7036 invoked by uid 89); 29 Mar 2014 01:26:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ie0-f180.google.com Received: from mail-ie0-f180.google.com (HELO mail-ie0-f180.google.com) (209.85.223.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 29 Mar 2014 01:26:43 +0000 Received: by mail-ie0-f180.google.com with SMTP id as1so5714417iec.11 for ; Fri, 28 Mar 2014 18:26:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc :content-type; bh=8+IrdpxTrmHcxrNa9NrjYUHQusQk3ug9BZ5CnQWJ0FM=; b=PcLy6uZfm0Y1sEaxUw4WK2snCQ37+P8w/bmFkofN9Fdtc/06NABSx2e7iEtbBk0cQs 3BVItwv7hLqJGwXrHkYEhod3p+mAipGNExo48jPP69fVlMaP1kVQycXNpwbfpnEkgHSa wSGCXVgt3P8LlEUsF1ZYAxFb14ub/PDXCy1Yn0r+dECdS14Z4F6p3/R4/Vkcv1y1IrT5 EXVvqHkUnTp1KKMsHhMWjJW5SlKT0tI6/dw1Vq+/PqdQeL73zimFbq5vnHP8gMKYszQ9 yrIVP16vlc3+Y3yEg8Sc6P7Eaxaju0OQ69tJH7ys9emtxF4zp9t60DrR/zI/Ctbuiip8 PmmQ== X-Gm-Message-State: ALoCoQnl0FXsF+EbwKUI4EOWfcy6rZ+PXbt1G7lYhNfNUuvV5gyjL8qVS/33lnEGpnIeaRbsPO8cjJ2suaEPwHSi37E+VkbRHtLws9i843z+drEVICwQ0UcEloOO+MTzFPitn16trrlTYCr/9FItV+0ItB/21j1IdD3pMnONG43JVS+UQqKsil5UkRl4WW5Pqm1ru/qOErOxLc5V0hBEtFkm6Sb5p9fEoA== MIME-Version: 1.0 X-Received: by 10.50.122.8 with SMTP id lo8mr41847769igb.31.1396056401773; Fri, 28 Mar 2014 18:26:41 -0700 (PDT) Received: by 10.64.7.225 with HTTP; Fri, 28 Mar 2014 18:26:41 -0700 (PDT) Date: Fri, 28 Mar 2014 18:26:41 -0700 Message-ID: Subject: [PATCH] Fixing PR60656 From: Cong Hou To: GCC Patches Cc: Jakub Jelinek This patch is fixing PR60656. Elements in a vector with vect_used_by_reduction property cannot be reordered if the use chain with this property does not have the same operation. Bootstrapped and tested on a x86-64 machine. OK for trunk? thanks, Cong break; diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e1d8666..d7d5b82 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2014-03-28 Cong Hou + + PR tree-optimization/60656 + * tree-vect-stmts.c (supportable_widening_operation): + Fix a bug that elements in a vector with vect_used_by_reduction + property are incorrectly reordered when the operation on it is not + consistant with the one in reduction operation. + 2014-03-10 Jakub Jelinek PR ipa/60457 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 41b6875..414a745 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-03-28 Cong Hou + + PR tree-optimization/60656 + * gcc.dg/vect/pr60656.c: New test. + 2014-03-10 Jakub Jelinek PR ipa/60457 diff --git a/gcc/testsuite/gcc.dg/vect/pr60656.c b/gcc/testsuite/gcc.dg/vect/pr60656.c new file mode 100644 index 0000000..ebaab62 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr60656.c @@ -0,0 +1,45 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +__attribute__ ((noinline)) long +foo () +{ + int v[] = {5000, 5001, 5002, 5003}; + long s = 0; + int i; + + for(i = 0; i < 4; ++i) + { + long P = v[i]; + s += P*P*P; + } + return s; +} + +long +bar () +{ + int v[] = {5000, 5001, 5002, 5003}; + long s = 0; + int i; + + for(i = 0; i < 4; ++i) + { + long P = v[i]; + s += P*P*P; + __asm__ volatile (""); + } + return s; +} + +int main() +{ + if (foo () != bar ()) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ + diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 70fb411..7442d0c 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -7827,7 +7827,16 @@ supportable_widening_operation (enum tree_code code, gimple stmt, stmt, vectype_out, vectype_in, code1, code2, multi_step_cvt, interm_types)) - return true; + { + tree lhs = gimple_assign_lhs (stmt); + use_operand_p dummy; + gimple use_stmt; + stmt_vec_info use_stmt_info = NULL; + if (single_imm_use (lhs, &dummy, &use_stmt) + && (use_stmt_info = vinfo_for_stmt (use_stmt)) + && STMT_VINFO_DEF_TYPE (use_stmt_info) == vect_reduction_def) + return true; + } c1 = VEC_WIDEN_MULT_LO_EXPR; c2 = VEC_WIDEN_MULT_HI_EXPR;