From patchwork Tue Mar 4 08:42:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 326189 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 6BA402C014B for ; Tue, 4 Mar 2014 19:43:38 +1100 (EST) 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=EJHMuUiK4OxB01+lyS+m3stQJvKLxZryX4+QEWhf4fHnUoqSDjVF0 8LYemSaRGNfACVoACqn8u/hYZFSfxOso8MwV7MFVOTFA96/Sm/DmeVHGQikREJco 292arpEXKW+i9kkSpUafekOCZhgPDPFmhh7ryV6DXY2jvQSegtTD8A= 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=e4ohVLvBjCbWRfzzLzgD4HJ3Dws=; b=vkSUXQ/Zwe7bWRWIJibk HB/gaVcriAj6bJ1W0fcrwATNXJLoxeRUEKiAa3oD0eXwDQDexMuWnVdKexUS7A8X 2V50lqPETKV6ofgmL4J2Zr/9vuNUmpJ2YMbdr7UUbhhuj0yLkxKM3mNuIRpTKdCd g7XzCeaVbfTsuaudVrtoDbI= Received: (qmail 15401 invoked by alias); 4 Mar 2014 08:43:31 -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 15390 invoked by uid 89); 4 Mar 2014 08:43:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Tue, 04 Mar 2014 08:43:30 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 2834B75029 for ; Tue, 4 Mar 2014 08:43:27 +0000 (UTC) Date: Tue, 4 Mar 2014 09:42:18 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR60382 Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 This fixes PR60382 where the vectorizer identified a double-reduction it cannot later re-identify properly. The only reasonable fix at this point is to not identify that as a double-reduction. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk, will apply to branch after testing there. Richard. 2014-03-04 Richard Biener PR tree-optimization/60382 * tree-vect-loop.c (vect_is_simple_reduction_1): Do not consider dead PHIs a reduction. * gcc.dg/vect/pr60382.c: New testcase. Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c (revision 208269) +++ gcc/tree-vect-loop.c (working copy) @@ -2193,6 +2193,12 @@ vect_is_simple_reduction_1 (loop_vec_inf || (!check_reduction && flow_loop_nested_p (vect_loop, loop))); name = PHI_RESULT (phi); + /* ??? If there are no uses of the PHI result the inner loop reduction + won't be detected as possibly double-reduction by vectorizable_reduction + because that tries to walk the PHI arg from the preheader edge which + can be constant. See PR60382. */ + if (has_zero_uses (name)) + return NULL; nloop_uses = 0; FOR_EACH_IMM_USE_FAST (use_p, imm_iter, name) { Index: gcc/testsuite/gcc.dg/vect/pr60382.c =================================================================== --- gcc/testsuite/gcc.dg/vect/pr60382.c (revision 0) +++ gcc/testsuite/gcc.dg/vect/pr60382.c (working copy) @@ -0,0 +1,32 @@ +#include "tree-vect.h" + +int a, b, c, e, f; + +void +foo () +{ + for (b = 0; b < 3; b++) + if (e) + { + for (c = 0; c < 4; c++) + { + if (b) + continue; + f = 1; + for (a = 0; a < 2; a++) + f |= 1; + } + for (;;) + ; + } +} + +int +main () +{ + check_vect (); + foo (); + return 0; +} + +/* { dg-final { cleanup-tree-dump "vect" } } */