From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 42540 invoked by alias); 12 Jan 2016 11:39:27 -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 42529 invoked by uid 89); 12 Jan 2016 11:39:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.9 required=5.0 tests=BAYES_50,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=sk:nested_, TREE_REAL_CST, gimple_convert, real_value_type X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Tue, 12 Jan 2016 11:39:24 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id EBB36AAC1 for ; Tue, 12 Jan 2016 11:39:20 +0000 (UTC) Date: Tue, 12 Jan 2016 11:39:00 -0000 From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR69053 Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2016-01/txt/msg00692.txt.bz2 Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2016-01-12 Richard Biener PR tree-optimization/69053 * tree-vect-loop.c (get_initial_def_for_reduction): Properly convert initial value for cond reductions. * g++.dg/torture/pr69053.C: New testcase. Index: gcc/tree-vect-loop.c =================================================================== *** gcc/tree-vect-loop.c (revision 232261) --- gcc/tree-vect-loop.c (working copy) *************** get_initial_def_for_reduction (gimple *s *** 4075,4084 **** tree *elts; int i; bool nested_in_vect_loop = false; - tree init_value; REAL_VALUE_TYPE real_init_val = dconst0; int int_init_val = 0; gimple *def_stmt = NULL; gcc_assert (vectype); nunits = TYPE_VECTOR_SUBPARTS (vectype); --- 4075,4084 ---- tree *elts; int i; bool nested_in_vect_loop = false; REAL_VALUE_TYPE real_init_val = dconst0; int int_init_val = 0; gimple *def_stmt = NULL; + gimple_seq stmts = NULL; gcc_assert (vectype); nunits = TYPE_VECTOR_SUBPARTS (vectype); *************** get_initial_def_for_reduction (gimple *s *** 4107,4122 **** return vect_create_destination_var (init_val, vectype); } - if (TREE_CONSTANT (init_val)) - { - if (SCALAR_FLOAT_TYPE_P (scalar_type)) - init_value = build_real (scalar_type, TREE_REAL_CST (init_val)); - else - init_value = build_int_cst (scalar_type, TREE_INT_CST_LOW (init_val)); - } - else - init_value = init_val; - switch (code) { case WIDEN_SUM_EXPR: --- 4107,4112 ---- *************** get_initial_def_for_reduction (gimple *s *** 4193,4199 **** break; } } ! init_def = build_vector_from_val (vectype, init_value); break; default: --- 4183,4192 ---- break; } } ! init_val = gimple_convert (&stmts, TREE_TYPE (vectype), init_val); ! if (! gimple_seq_empty_p (stmts)) ! gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts); ! init_def = build_vector_from_val (vectype, init_val); break; default: Index: gcc/testsuite/g++.dg/torture/pr69053.C =================================================================== *** gcc/testsuite/g++.dg/torture/pr69053.C (revision 0) --- gcc/testsuite/g++.dg/torture/pr69053.C (working copy) *************** *** 0 **** --- 1,17 ---- + // { dg-do compile } + // { dg-additional-options "-march=core-avx2" { target x86_64-*-* i?86-*-* } } + struct A { + int *elem[1]; + }; + int a, d, e; + A *b; + int *c; + int main() + { + int *f = 0; + for (; e; e++) + if (b->elem[e]) + f = c; + if (f) + a = d; + }