From patchwork Mon Oct 21 11:31:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1180510 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-511414-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="IMbUAdAK"; 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 46xZGD3YWcz9sNw for ; Mon, 21 Oct 2019 22:31:14 +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=LJca8QN0goLQkenP5ikZ3EJOzgFe1ZgVuC4pvP+NQMRw1oW/kGonK 8Rw7iGlakONhENJ3ZFJc5kHlTXUH0Dwt1mjj/XxAR5eBK09YDu49KYAUyVk4IAjg fvD85tdTsw3Bvjksmx8z/KGFU3S06/JcHxK1HGUroCSBtclpWxR9dQ= 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=yluOVX1HC8Esg5Hf6G4taEmQ8Uk=; b=IMbUAdAKHbOBFJMZK/JS d+U6cacYvMsfWUEoiJImJW1bJs+kqhB/vo25Mtt/KI4IdqZV3lXM+VjTqMKWIz7O q3yJWpHW6CvkCOobHGL/D4L9tPGyBmgvVpubhAFllb4w6FbZxzIPNGd2fFyZ+CIt +d3vcMGDR7BqWijvBWTyhqE= Received: (qmail 114312 invoked by alias); 21 Oct 2019 11:31:07 -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 114299 invoked by uid 89); 21 Oct 2019 11:31:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, 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; Mon, 21 Oct 2019 11:31:05 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id AB727B657 for ; Mon, 21 Oct 2019 11:31:03 +0000 (UTC) Date: Mon, 21 Oct 2019 13:31:03 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR92161 Message-ID: User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Bootstrapped & tested on x86_64-unknown-linux-gnu, applied. Richard. 2019-10-21 Richard Biener PR tree-optimization/92161 * tree-vect-loop.c (vect_analyze_loop_2): Reset stmts def-type for reductions. * gfortran.dg/pr92161.f: New testcase. Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c (revision 277237) +++ gcc/tree-vect-loop.c (working copy) @@ -2260,6 +2260,17 @@ again: { stmt_vec_info stmt_info = loop_vinfo->lookup_stmt (gsi_stmt (si)); STMT_SLP_TYPE (stmt_info) = loop_vect; + if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_reduction_def + || STMT_VINFO_DEF_TYPE (stmt_info) == vect_double_reduction_def) + { + /* vectorizable_reduction adjusts reduction stmt def-types, + restore them to that of the PHI. */ + STMT_VINFO_DEF_TYPE (STMT_VINFO_REDUC_DEF (stmt_info)) + = STMT_VINFO_DEF_TYPE (stmt_info); + STMT_VINFO_DEF_TYPE (vect_stmt_to_vectorize + (STMT_VINFO_REDUC_DEF (stmt_info))) + = STMT_VINFO_DEF_TYPE (stmt_info); + } } for (gimple_stmt_iterator si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si)) Index: gcc/testsuite/gfortran.dg/pr92161.f =================================================================== --- gcc/testsuite/gfortran.dg/pr92161.f (nonexistent) +++ gcc/testsuite/gfortran.dg/pr92161.f (working copy) @@ -0,0 +1,23 @@ +! { dg-do compile } +! { dg-options "-O1 -ftree-loop-vectorize -fno-signed-zeros -fno-trapping-math" } +! { dg-additional-options "-mvsx" { target { powerpc*-*-* } } } + COMPLEX FUNCTION R1 (ZR, CC, EA, U6) + + INTEGER ZR, U6, FZ, J2 + COMPLEX EA(*), CC + DOUBLE PRECISION OS, GA, YU, XT + + OS = DBLE(REAL(CC)) + GA = DBLE(AIMAG(CC)) + J2 = 1 + + DO 5 FZ = 1, ZR + YU = DBLE(REAL(EA(J2))) + XT = DBLE(AIMAG(EA(J2))) + OS = OS + (YU * 2) - (XT * 2) + GA = GA + (YU * 3) + (XT * 3) + J2 = J2 + U6 + 5 CONTINUE + R1 = CMPLX(REAL(OS), REAL(GA)) + RETURN + END