From patchwork Wed Nov 13 08:03:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1194116 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-513191-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="kWx0OtZh"; dkim-atps=neutral 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 47CcZk1gyrz9sNH for ; Wed, 13 Nov 2019 19:04:11 +1100 (AEDT) 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=y3OZXA8e5Ilfwjx2e4YS792g1nCLskkoqwzx9RuYkvFAxdDHfFpjU egwmJF3N119rhRg/eZUZm+NIL6tir+K404SL+qcUP9WoqZWoSkpKPBmVa66wH1sw 5tUDKZF7ySlqc7t/lVm3lWztBt+6b6WXZGgJl3vU8sifikx6WoWt0E= 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=+mbGngzEBvka/0ZVkvpkUxpcES0=; b=kWx0OtZhUAZXKjrv2LQu tHpoy1geMtGWwKXBFbFYJyfg1caP5C0lQcCLwI/vydCZVFGh6Ab+zsVh13elN/hz HL9oOWvhwD/9ra4fLhypSOObvonNP4OVLtHxVaIs0FiYM7cPke4lOqr4bN6jE7mU oKbaCJRBErub9d6l7l49E1g= Received: (qmail 6500 invoked by alias); 13 Nov 2019 08:04:04 -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 6490 invoked by uid 89); 13 Nov 2019 08:04:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 13 Nov 2019 08:04:03 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 9BC72ABD6 for ; Wed, 13 Nov 2019 08:03:59 +0000 (UTC) Date: Wed, 13 Nov 2019 09:03:59 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR92473 Message-ID: User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2019-11-13 Richard Biener PR tree-optimization/92473 * tree-vect-loop.c (vect_create_epilog_for_reduction): Perform direct optab reduction in the correct type. Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c (revision 278094) +++ gcc/tree-vect-loop.c (working copy) @@ -4739,31 +4739,13 @@ vect_create_epilog_for_reduction (stmt_v dump_printf_loc (MSG_NOTE, vect_location, "Reduce using direct vector reduction.\n"); + gimple_seq stmts = NULL; + new_phi_result = gimple_convert (&stmts, vectype, new_phi_result); vec_elem_type = TREE_TYPE (TREE_TYPE (new_phi_result)); - if (!useless_type_conversion_p (scalar_type, vec_elem_type)) - { - tree tmp_dest - = vect_create_destination_var (scalar_dest, vec_elem_type); - epilog_stmt = gimple_build_call_internal (reduc_fn, 1, - new_phi_result); - gimple_set_lhs (epilog_stmt, tmp_dest); - new_temp = make_ssa_name (tmp_dest, epilog_stmt); - gimple_set_lhs (epilog_stmt, new_temp); - gsi_insert_before (&exit_gsi, epilog_stmt, GSI_SAME_STMT); - - epilog_stmt = gimple_build_assign (new_scalar_dest, NOP_EXPR, - new_temp); - } - else - { - epilog_stmt = gimple_build_call_internal (reduc_fn, 1, - new_phi_result); - gimple_set_lhs (epilog_stmt, new_scalar_dest); - } - - new_temp = make_ssa_name (new_scalar_dest, epilog_stmt); - gimple_set_lhs (epilog_stmt, new_temp); - gsi_insert_before (&exit_gsi, epilog_stmt, GSI_SAME_STMT); + new_temp = gimple_build (&stmts, as_combined_fn (reduc_fn), + vec_elem_type, new_phi_result); + new_temp = gimple_convert (&stmts, scalar_type, new_temp); + gsi_insert_seq_before (&exit_gsi, stmts, GSI_SAME_STMT); if ((STMT_VINFO_REDUC_TYPE (reduc_info) == INTEGER_INDUC_COND_REDUCTION) && induc_val)