From patchwork Fri Dec 18 09:37:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 558794 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 422C71401AF for ; Fri, 18 Dec 2015 20:37:50 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=JE6tUfkR; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=XyrZ6/RbyQPCLODP73fawZDA6OehLqn+3vovq2xmRtO6cKgnLhTH3 R+z2FWPxbyfRcoGceU8z1fG541p4caBgfupWTIPR0MxUvao1WNU7xWJTvmClz5Cg dT6w98KnxrDfLbQe9lgOTEYnWXbLWIuJ4vYbQkLxhCd8F/Ned1saK0= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=RPpezNcgbVR//2L/AkzlRzYOKBY=; b=JE6tUfkRwFVDNfMNe9fq USEii+UlVufwX9pqamJiHUuwt/SoRAEtV1YVXtXRGElpwNI+KDaS6ILIiOm8CsWO B8nPhbbRPvCDDFFn+1C5M3+4/CeLHuOJ182x98sI23billlNsecmQsuh5D9xAakt 1cAiMV1tNV2BHScV8tEU3nQ= Received: (qmail 45544 invoked by alias); 18 Dec 2015 09:37:42 -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 45527 invoked by uid 89); 18 Dec 2015 09:37:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=sum, 2015-12-18 X-HELO: mail-io0-f178.google.com Received: from mail-io0-f178.google.com (HELO mail-io0-f178.google.com) (209.85.223.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 18 Dec 2015 09:37:40 +0000 Received: by mail-io0-f178.google.com with SMTP id 186so85212313iow.0 for ; Fri, 18 Dec 2015 01:37:39 -0800 (PST) X-Received: by 10.107.167.18 with SMTP id q18mr3381646ioe.141.1450431458022; Fri, 18 Dec 2015 01:37:38 -0800 (PST) Received: from msticlxl57.ims.intel.com ([192.198.151.43]) by smtp.gmail.com with ESMTPSA id b184sm2779297iob.36.2015.12.18.01.37.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Dec 2015 01:37:37 -0800 (PST) Date: Fri, 18 Dec 2015 12:37:07 +0300 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Subject: [PATCH, PR68956, committed] Fix constants used for boolean vectors Message-ID: <20151218093707.GD54845@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes Hi, Here is a trivial patch to fix boolean vector invariants. Bootstrapped and tested on x86_64-pc-linux-gnu. Applied to trunk. Thanks, Ilya --- gcc/ 2015-12-18 Ilya Enkovich PR tree-optimization/68956 * tree-vect-stmts.c (vect_init_vector): Fix constants used for boolean vectors. gcc/testsuite 2015-12-18 Ilya Enkovich PR tree-optimization/68956 * gcc.target/i386/pr68956.c: New test. diff --git a/gcc/testsuite/gcc.target/i386/pr68956.c b/gcc/testsuite/gcc.target/i386/pr68956.c new file mode 100644 index 0000000..4fb2ced --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr68956.c @@ -0,0 +1,67 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -ffast-math -mfpmath=sse -mavx2 -ftree-vectorize" } */ +/* { dg-require-effective-target avx2 } */ + +#include "avx2-check.h" + +extern void abort (void); + +int l; + +static void __attribute__((noclone,noinline)) +test1 (double *in1, double *in2, double *out, + int l1, int l2, int *n) +{ + double sum; + int na = n[0]; + int nb = n[1]; + int i; + _Bool ic, jc; + + jc = (l > na) && (l > nb); + for (int i = 0; i < l2; i++) + { + ic = (i <= na) && (i <= nb); + sum = 0; + if (ic && jc) + sum = in1[i] + in2[i]; + out[i] = sum; + } +} + +static void +avx2_test (void) +{ + double in1[40], in2[40], out[40], sum; + int n[2],l1,l2,i,na,nb; + _Bool ic, jc; + + l = 0; + l1 = 8; + l2 = 40; + n[0] = 14; + n[1] = 13; + + for (i = 0; i < l2; i++) + { + in1[i] = i; + in2[i] = i; + out[i] = 0; + } + + test1 (in1, in2, out, l1, l2, n); + + na = n[0]; + nb = n[1]; + + jc = (l > na) && (l > nb); + for (int i = 0; i < l2; i++) + { + ic = (i <= na) && (i <= nb); + sum = 0; + if (ic && jc) + sum = in1[i] + in2[i]; + if (out[i] != sum) + abort (); + } +} diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index b1342fb..7c6fa73 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -1304,8 +1304,8 @@ vect_init_vector (gimple *stmt, tree val, tree type, gimple_stmt_iterator *gsi) all zeros or all ones value before building a vector. */ if (VECTOR_BOOLEAN_TYPE_P (type)) { - tree true_val = build_zero_cst (TREE_TYPE (type)); - tree false_val = build_all_ones_cst (TREE_TYPE (type)); + tree true_val = build_all_ones_cst (TREE_TYPE (type)); + tree false_val = build_zero_cst (TREE_TYPE (type)); if (CONSTANT_CLASS_P (val)) val = integer_zerop (val) ? false_val : true_val;