From patchwork Thu Jul 27 13:43:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 794407 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-459170-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="TJz19uSn"; 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 3xJCqr0QQxz9s3T for ; Thu, 27 Jul 2017 23:43:51 +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=Dgwl8TFi7L86gLmyalGBks0BnG8T1Jt7gYimd7B17pexmMYaEzAQy Qb/q6E22cXHs3D8cqSR29ROMrHaf9Obm1VXQP7bCfSv0DpPyBCA0gu+2lBWmJGTa BBKXjMcl4bgIRK3O4SgZuYwAaryMrYsjNGhCUb3LTHUqZMvx5G/KSE= 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=k6c0HP1JPeTl8IARUs3Dl6Uh6e4=; b=TJz19uSniyb36noqlNcD ECehIjYfSvxt+OIAXzlWP3Dm7C/cPTAAI1VSKx0Xjk0EkUZ2LPg81A+LWdSXO9TS t2r3CLjj/jEAahRUJwtc06V8TkWhqcGPK2AHRsX7mAjP2J7uxRPH90/8RlZo9W1S tntNmK1lM+k2y3RYi3Ir99E= Received: (qmail 15720 invoked by alias); 27 Jul 2017 13:43:41 -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 14829 invoked by uid 89); 27 Jul 2017 13:43:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 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; Thu, 27 Jul 2017 13:43:38 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 5509AABB8 for ; Thu, 27 Jul 2017 13:43:36 +0000 (UTC) Date: Thu, 27 Jul 2017 15:43:33 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR81571 Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 The following fixes PR81571. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2017-07-27 Richard Biener PR tree-optimization/81571 * tree-vect-slp.c (vect_build_slp_tree): Properly verify reduction PHIs. * gcc.dg/torture/pr81571.c: New testcase. Index: gcc/tree-vect-slp.c =================================================================== --- gcc/tree-vect-slp.c (revision 250607) +++ gcc/tree-vect-slp.c (working copy) @@ -947,11 +948,27 @@ vect_build_slp_tree (vec_info *vinfo, the recursion. */ if (gimple_code (stmt) == GIMPLE_PHI) { + vect_def_type def_type = STMT_VINFO_DEF_TYPE (vinfo_for_stmt (stmt)); /* Induction from different IVs is not supported. */ - if (STMT_VINFO_DEF_TYPE (vinfo_for_stmt (stmt)) == vect_induction_def) - FOR_EACH_VEC_ELT (stmts, i, stmt) - if (stmt != stmts[0]) - return NULL; + if (def_type == vect_induction_def) + { + FOR_EACH_VEC_ELT (stmts, i, stmt) + if (stmt != stmts[0]) + return NULL; + } + else + { + /* Else def types have to match. */ + FOR_EACH_VEC_ELT (stmts, i, stmt) + { + /* But for reduction chains only check on the first stmt. */ + if (GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)) + && GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)) != stmt) + continue; + if (STMT_VINFO_DEF_TYPE (vinfo_for_stmt (stmt)) != def_type) + return NULL; + } + } node = vect_create_new_slp_node (stmts); return node; } Index: gcc/testsuite/gcc.dg/torture/pr81571.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr81571.c (nonexistent) +++ gcc/testsuite/gcc.dg/torture/pr81571.c (working copy) @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +int a, b, c, d; +short fn1(int p1, int p2) { return p1; } + +int fn2(int p1) {} + +int main() +{ + for (; c; c++) + a |= fn1(1, a) | fn2(b |= d); + return 0; +}