From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 103321 invoked by alias); 12 Nov 2015 15:49:15 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 103308 invoked by uid 89); 12 Nov 2015 15:49:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ig0-f178.google.com Received: from mail-ig0-f178.google.com (HELO mail-ig0-f178.google.com) (209.85.213.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 12 Nov 2015 15:49:13 +0000 Received: by igl9 with SMTP id 9so99925557igl.0 for ; Thu, 12 Nov 2015 07:49:11 -0800 (PST) X-Received: by 10.50.107.3 with SMTP id gy3mr15058429igb.48.1447343351402; Thu, 12 Nov 2015 07:49:11 -0800 (PST) Received: from msticlxl57.ims.intel.com (jfdmzpr03-ext.jf.intel.com. [134.134.139.72]) by smtp.gmail.com with ESMTPSA id 124sm4025590ioz.10.2015.11.12.07.49.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Nov 2015 07:49:10 -0800 (PST) Date: Thu, 12 Nov 2015 15:49:00 -0000 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix ICE for masked store of boolean value Message-ID: <20151112154842.GF51435@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg01551.txt.bz2 Hi, We may get ICE in vectorizer in case stored value get vectype not compatible with a storage. This may happen for bool values. This patch fixes ICE. Bootstrapped and tested on x86_64-unknown-linux-gnu. OK for trunk? Thanks, Ilya -- gcc/ 2015-11-12 Ilya Enkovich * tree-vect-stmts.c (vectorizable_mask_load_store): Check types of stored value and storage are compatible. gcc/testsuite/ 2015-11-12 Ilya Enkovich * g++.dg/vect/simd-mask-store-bool.cc: New test. diff --git a/gcc/testsuite/g++.dg/vect/simd-mask-store-bool.cc b/gcc/testsuite/g++.dg/vect/simd-mask-store-bool.cc new file mode 100644 index 0000000..c5f0458 --- /dev/null +++ b/gcc/testsuite/g++.dg/vect/simd-mask-store-bool.cc @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_condition } */ +/* { dg-additional-options "-mavx512bw" { target { i?86-*-* x86_64-*-* } } } */ + +#define N 1024 + +int a[N], b[N], c[N]; +bool d[N]; + +void +test (void) +{ + int i; +#pragma omp simd safelen(64) + for (i = 0; i < N; i++) + if (a[i] > 0) + d[i] = b[i] > c[i]; +} diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index cfe30e0..7870b29 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -1688,6 +1688,7 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi, bool nested_in_vect_loop = nested_in_vect_loop_p (loop, stmt); struct data_reference *dr = STMT_VINFO_DATA_REF (stmt_info); tree vectype = STMT_VINFO_VECTYPE (stmt_info); + tree rhs_vectype = NULL_TREE; tree mask_vectype; tree elem_type; gimple *new_stmt; @@ -1757,6 +1758,13 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi, if (!mask_vectype) return false; + if (is_store) + { + tree rhs = gimple_call_arg (stmt, 3); + if (!vect_is_simple_use (rhs, loop_vinfo, &def_stmt, &dt, &rhs_vectype)) + return false; + } + if (STMT_VINFO_GATHER_SCATTER_P (stmt_info)) { gimple *def_stmt; @@ -1790,16 +1798,11 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi, else if (!VECTOR_MODE_P (TYPE_MODE (vectype)) || !can_vec_mask_load_store_p (TYPE_MODE (vectype), TYPE_MODE (mask_vectype), - !is_store)) + !is_store) + || (rhs_vectype + && !useless_type_conversion_p (vectype, rhs_vectype))) return false; - if (is_store) - { - tree rhs = gimple_call_arg (stmt, 3); - if (!vect_is_simple_use (rhs, loop_vinfo, &def_stmt, &dt)) - return false; - } - if (!vec_stmt) /* transformation not required. */ { STMT_VINFO_TYPE (stmt_info) = call_vec_info_type;