From patchwork Tue Oct 26 15:53:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Rosen X-Patchwork-Id: 69261 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]) by ozlabs.org (Postfix) with SMTP id 9560CB70A5 for ; Wed, 27 Oct 2010 02:54:17 +1100 (EST) Received: (qmail 12471 invoked by alias); 26 Oct 2010 15:54:13 -0000 Received: (qmail 12460 invoked by uid 22791); 26 Oct 2010 15:54:11 -0000 X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL, BAYES_00, MAY_BE_FORGED, TW_TM, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mtagate3.de.ibm.com (HELO mtagate3.de.ibm.com) (195.212.17.163) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 26 Oct 2010 15:54:06 +0000 Received: from d12nrmr1707.megacenter.de.ibm.com (d12nrmr1707.megacenter.de.ibm.com [9.149.167.81]) by mtagate3.de.ibm.com (8.13.1/8.13.1) with ESMTP id o9QFs3rN012209 for ; Tue, 26 Oct 2010 15:54:03 GMT Received: from d12av05.megacenter.de.ibm.com (d12av05.megacenter.de.ibm.com [9.149.165.216]) by d12nrmr1707.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o9QFs3o53547196 for ; Tue, 26 Oct 2010 17:54:03 +0200 Received: from d12av05.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av05.megacenter.de.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o9QFs2wJ019709 for ; Tue, 26 Oct 2010 17:54:02 +0200 Received: from d12mc102.megacenter.de.ibm.com (d12nrml1506.megacenter.de.ibm.com [9.149.165.56] (may be forged)) by d12av05.megacenter.de.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id o9QFs2qm019706 for ; Tue, 26 Oct 2010 17:54:02 +0200 Subject: [patch] Fix PR tree-optimization/46167 X-KeepSent: 4B318A2E:A2837690-C22577C8:0054DD52; type=4; name=$KeepSent To: gcc-patches@gcc.gnu.org Message-ID: From: Ira Rosen Date: Tue, 26 Oct 2010 17:53:55 +0200 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII X-IsSubscribed: yes 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 Hi, This patch adds a check that a basic block exists before calling flow_bb_inside_loop_p. Bootstrapped and tested on x86_64-suse-linux. Committed to trunk. Now testing the patch for 4.5 on x86_64-suse-linux. OK for 4.5 once the testing completes? Thanks, Ira ChangeLog: PR tree-optimization/46167 * tree-vect-patterns.c (vect_recog_dot_prod_pattern): Check that there is basic block for the statement. testsuite/ChangeLog: PR tree-optimization/46167 * gcc.dg/vect/O-pr46167.c: New. * gcc.dg/vect/vect.exp: Run tests with -O. 4.6 patch: /* FORNOW. Can continue analyzing the def-use chain when this stmt in a phi Index: testsuite/gcc.dg/vect/O-pr46167.c =================================================================== --- testsuite/gcc.dg/vect/O-pr46167.c (revision 0) +++ testsuite/gcc.dg/vect/O-pr46167.c (revision 0) @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +int foo (char c, int i) +{ + int s = 0; + while (i--) + s += c; + return s; +} + +/* { dg-final { cleanup-tree-dump "vect" } } */ Index: testsuite/gcc.dg/vect/vect.exp =================================================================== --- testsuite/gcc.dg/vect/vect.exp (revision 165969) +++ testsuite/gcc.dg/vect/vect.exp (working copy) @@ -126,6 +126,11 @@ set O1_VECTCFLAGS $DEFAULT_VECTCFLAGS lappend O1_VECTCFLAGS "-O1" lappend O1_VECTCFLAGS "-fdump-tree-vect-details" +global O_VECTCFLAGS +set O_VECTCFLAGS $DEFAULT_VECTCFLAGS +lappend O_VECTCFLAGS "-O" +lappend O_VECTCFLAGS "-fdump-tree-vect-details" + lappend DEFAULT_VECTCFLAGS "-O2" # Tests that should be run without generating dump info @@ -287,6 +292,10 @@ dg-runtest [lsort [glob -nocomplain $src dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O1-*.\[cS\]]] \ "" $O1_VECTCFLAGS +# With -O +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O-*.\[cS\]]] \ + "" $O_VECTCFLAGS + # -fno-tree-reassoc set VECT_SLP_CFLAGS $SAVED_VECT_SLP_CFLAGS lappend VECT_SLP_CFLAGS "-fno-tree-reassoc" Index: tree-vect-patterns.c =================================================================== --- tree-vect-patterns.c (revision 165969) +++ tree-vect-patterns.c (working copy) @@ -257,7 +257,7 @@ vect_recog_dot_prod_pattern (gimple last stmt = SSA_NAME_DEF_STMT (oprnd0); /* It could not be the dot_prod pattern if the stmt is outside the loop. */ - if (!flow_bb_inside_loop_p (loop, gimple_bb (stmt))) + if (!gimple_bb (stmt) || !flow_bb_inside_loop_p (loop, gimple_bb (stmt))) return NULL; /* FORNOW. Can continue analyzing the def-use chain when this stmt in a phi 4.5 patch: Index: testsuite/gcc.dg/vect/O-pr46167.c =================================================================== --- testsuite/gcc.dg/vect/O-pr46167.c (revision 0) +++ testsuite/gcc.dg/vect/O-pr46167.c (revision 0) @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +int foo (char c, int i) +{ + int s = 0; + while (i--) + s += c; + return s; +} + +/* { dg-final { cleanup-tree-dump "vect" } } */ Index: testsuite/gcc.dg/vect/vect.exp =================================================================== --- testsuite/gcc.dg/vect/vect.exp (revision 165269) +++ testsuite/gcc.dg/vect/vect.exp (working copy) @@ -122,6 +122,11 @@ set O1_VECTCFLAGS $DEFAULT_VECTCFLAGS lappend O1_VECTCFLAGS "-O1" lappend O1_VECTCFLAGS "-fdump-tree-vect-details" +global O_VECTCFLAGS +set O_VECTCFLAGS $DEFAULT_VECTCFLAGS +lappend O_VECTCFLAGS "-O" +lappend O_VECTCFLAGS "-fdump-tree-vect-details" + lappend DEFAULT_VECTCFLAGS "-O2" # Tests that should be run without generating dump info @@ -283,6 +288,10 @@ dg-runtest [lsort [glob -nocomplain $src dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O1-*.\[cS\]]] \ "" $O1_VECTCFLAGS +# With -O +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O-*.\[cS\]]] \ + "" $O_VECTCFLAGS + # -fno-tree-reassoc set VECT_SLP_CFLAGS $SAVED_VECT_SLP_CFLAGS lappend VECT_SLP_CFLAGS "-fno-tree-reassoc" Index: tree-vect-patterns.c =================================================================== --- tree-vect-patterns.c (revision 165269) +++ tree-vect-patterns.c (working copy) @@ -256,7 +256,7 @@ vect_recog_dot_prod_pattern (gimple last stmt = SSA_NAME_DEF_STMT (oprnd0); /* It could not be the dot_prod pattern if the stmt is outside the loop. */ - if (!flow_bb_inside_loop_p (loop, gimple_bb (stmt))) + if (!gimple_bb (stmt) || !flow_bb_inside_loop_p (loop, gimple_bb (stmt))) return NULL;