From patchwork Tue Jan 16 15:11:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 861687 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-471385-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="OKA6+2a1"; 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 3zLYbT144cz9s83 for ; Wed, 17 Jan 2018 02:11:48 +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=LTWeHL1gvf+YrJ95u20wPpkdt06zKSHJnYfLnQfFR+AflJIWueVQW wN2TDUmn51loHgmsT53ATkyVs24AqqvSpodXmvtius2TrlpfO0Yb4U/Kmrv1EZVA wmi2ENlQL+Tnwizat+d2yaSK9f0yIae1qbbBTTT6fyJ+LwA1/OS/bk= 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=LTEm+PaPHxFTkP6synkdO9hTYTo=; b=OKA6+2a1e1gFhbpXuUei 9qrU1rFPtaEHqQ1oiebedt4q409lr8nxFgrLlF5CbqAJNpGArXeF9OZVTUKOWKXa Z74i+yM2oTxeKCOVMxFPlNjn44pJ+PSYnEtL8CbynegoVt4d26095eSTrewgG1ZG iZ8BWjRcwA08DpWrbXaH7fw= Received: (qmail 57978 invoked by alias); 16 Jan 2018 15:11: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 57568 invoked by uid 89); 16 Jan 2018 15:11:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:1866 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 ESMTP; Tue, 16 Jan 2018 15:11:34 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 6EB98AE07 for ; Tue, 16 Jan 2018 15:11:32 +0000 (UTC) Date: Tue, 16 Jan 2018 16:11:32 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR83867 Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2018-01-16 Richard Biener PR tree-optimization/83867 * tree-vect-stmts.c (vect_transform_stmt): Precompute nested_in_vect_loop_p since the scalar stmt may get invalidated. * gcc.dg/vect/pr83867.c: New testcase. Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c (revision 256722) +++ gcc/tree-vect-stmts.c (working copy) @@ -9426,6 +9426,11 @@ vect_transform_stmt (gimple *stmt, gimpl gcc_assert (slp_node || !PURE_SLP_STMT (stmt_info)); gimple *old_vec_stmt = STMT_VINFO_VEC_STMT (stmt_info); + bool nested_p = (STMT_VINFO_LOOP_VINFO (stmt_info) + && nested_in_vect_loop_p + (LOOP_VINFO_LOOP (STMT_VINFO_LOOP_VINFO (stmt_info)), + stmt)); + switch (STMT_VINFO_TYPE (stmt_info)) { case type_demotion_vec_info_type: @@ -9525,9 +9530,7 @@ vect_transform_stmt (gimple *stmt, gimpl /* Handle inner-loop stmts whose DEF is used in the loop-nest that is being vectorized, but outside the immediately enclosing loop. */ if (vec_stmt - && STMT_VINFO_LOOP_VINFO (stmt_info) - && nested_in_vect_loop_p (LOOP_VINFO_LOOP ( - STMT_VINFO_LOOP_VINFO (stmt_info)), stmt) + && nested_p && STMT_VINFO_TYPE (stmt_info) != reduc_vec_info_type && (STMT_VINFO_RELEVANT (stmt_info) == vect_used_in_outer || STMT_VINFO_RELEVANT (stmt_info) == Index: gcc/testsuite/gcc.dg/vect/pr83867.c =================================================================== --- gcc/testsuite/gcc.dg/vect/pr83867.c (nonexistent) +++ gcc/testsuite/gcc.dg/vect/pr83867.c (working copy) @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O -ftrapv" } */ + +int +k5 (int u5, int aw) +{ + int v6; + + while (u5 < 1) + { + while (v6 < 4) + ++v6; + + v6 = 0; + aw += u5 > 0; + ++u5; + } + + return aw; +}