From patchwork Fri Sep 20 08:35:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1165101 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-509342-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="iKHiDDsv"; 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 46ZRqr059zz9s7T for ; Fri, 20 Sep 2019 18:35:35 +1000 (AEST) 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=v54wv3nzIllvhH/LNBEWvZ3PU5VDqqV9nxvpiO2E5JlF5QugZXMsD sy48G/Ogr/HJjFM3fiqvipLzgKO2ugKE3YSghPn+B4RMq0HkBJjSo5K4PHeAy8Sv mDHK0qwxWcRe2+HiIA+YMRDsirnGEbjeguyzAdxBG6DonxwluNxhRk= 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=OEevBCuoSusu5j7Z333rjpZcTU0=; b=iKHiDDsv46dwirVbV7/K qPxFd1S46wmh4CjvMRSwp35QLb3AfDk21Tjb6Q9eTbnNaaIY8naOsWUZFe9L8UoG tqSrlSN3uXVfKDdSieSkVZQhcCB0foxF6OqTAlXJ1tUZnz0HWtnVZjxf4XblGJt0 j4KbesBR7debibU5w2owG9Y= Received: (qmail 59247 invoked by alias); 20 Sep 2019 08:35:27 -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 59239 invoked by uid 89); 20 Sep 2019 08:35:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-12.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, SPF_PASS autolearn=ham version=3.3.1 spammy=gcc_assert 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; Fri, 20 Sep 2019 08:35:24 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 824A7ACF2 for ; Fri, 20 Sep 2019 08:35:22 +0000 (UTC) Date: Fri, 20 Sep 2019 10:35:22 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR91822 Message-ID: User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 The following restores the for_reduction parameter. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2019-09-20 Richard Biener PR tree-optimization/91822 * tree-vectorizer.h (vectorizable_condition): Restore for_reduction parameter. * tree-vect-loop.c (vectorizable_reduction): Adjust asserts for reduc_index in nested cycles, adjust vectorizable_condition calls. * tree-vect-stmts.c (vectorizable_condition): Restore for_reduction parameter. (vect_analyze_stmt): Adjust. (vect_transform_stmt): Likewise. Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c (revision 275988) +++ gcc/tree-vect-loop.c (working copy) @@ -6534,9 +6534,10 @@ vectorizable_reduction (stmt_vec_info st { /* Only call during the analysis stage, otherwise we'll lose STMT_VINFO_TYPE. */ - gcc_assert (reduc_index > 0); + gcc_assert (nested_cycle || reduc_index > 0); if (!vec_stmt && !vectorizable_condition (stmt_info, gsi, NULL, - reduc_index, NULL, cost_vec)) + true, reduc_index, + NULL, cost_vec)) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, @@ -6991,7 +6992,7 @@ vectorizable_reduction (stmt_vec_info st { gcc_assert (!slp_node && reduc_index > 0); return vectorizable_condition (stmt_info, gsi, vec_stmt, - reduc_index, NULL, NULL); + true, reduc_index, NULL, NULL); } /* Create the destination vector */ @@ -7021,8 +7022,8 @@ vectorizable_reduction (stmt_vec_info st { if (code == COND_EXPR) { - gcc_assert (!slp_node && reduc_index > 0); - vectorizable_condition (stmt_info, gsi, vec_stmt, + gcc_assert (!slp_node && (nested_cycle || reduc_index > 0)); + vectorizable_condition (stmt_info, gsi, vec_stmt, true, reduc_index, NULL, NULL); break; } Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c (revision 275988) +++ gcc/tree-vect-stmts.c (working copy) @@ -9778,7 +9778,8 @@ vect_is_simple_cond (tree cond, vec_info bool vectorizable_condition (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, - stmt_vec_info *vec_stmt, int reduc_index, + stmt_vec_info *vec_stmt, bool for_reduction, + int reduc_index, slp_tree slp_node, stmt_vector_for_cost *cost_vec) { vec_info *vinfo = stmt_info->vinfo; @@ -9807,7 +9808,6 @@ vectorizable_condition (stmt_vec_info st vec vec_oprnds3 = vNULL; tree vec_cmp_type; bool masked = false; - bool for_reduction = (reduc_index > 0); if (for_reduction && STMT_SLP_TYPE (stmt_info)) return false; @@ -10668,7 +10668,7 @@ vect_analyze_stmt (stmt_vec_info stmt_in node_instance, cost_vec) || vectorizable_induction (stmt_info, NULL, NULL, node, cost_vec) || vectorizable_shift (stmt_info, NULL, NULL, node, cost_vec) - || vectorizable_condition (stmt_info, NULL, NULL, 0, node, + || vectorizable_condition (stmt_info, NULL, NULL, false, -1, node, cost_vec) || vectorizable_comparison (stmt_info, NULL, NULL, node, cost_vec)); @@ -10687,7 +10687,7 @@ vect_analyze_stmt (stmt_vec_info stmt_in || vectorizable_load (stmt_info, NULL, NULL, node, node_instance, cost_vec) || vectorizable_store (stmt_info, NULL, NULL, node, cost_vec) - || vectorizable_condition (stmt_info, NULL, NULL, 0, node, + || vectorizable_condition (stmt_info, NULL, NULL, false, -1, node, cost_vec) || vectorizable_comparison (stmt_info, NULL, NULL, node, cost_vec)); @@ -10792,7 +10792,7 @@ vect_transform_stmt (stmt_vec_info stmt_ break; case condition_vec_info_type: - done = vectorizable_condition (stmt_info, gsi, &vec_stmt, 0, + done = vectorizable_condition (stmt_info, gsi, &vec_stmt, false, -1, slp_node, NULL); gcc_assert (done); break; Index: gcc/tree-vectorizer.h =================================================================== --- gcc/tree-vectorizer.h (revision 275988) +++ gcc/tree-vectorizer.h (working copy) @@ -1534,7 +1534,7 @@ extern void vect_remove_stores (stmt_vec extern opt_result vect_analyze_stmt (stmt_vec_info, bool *, slp_tree, slp_instance, stmt_vector_for_cost *); extern bool vectorizable_condition (stmt_vec_info, gimple_stmt_iterator *, - stmt_vec_info *, int, slp_tree, + stmt_vec_info *, bool, int, slp_tree, stmt_vector_for_cost *); extern bool vectorizable_shift (stmt_vec_info, gimple_stmt_iterator *, stmt_vec_info *, slp_tree,