From patchwork Tue Mar 11 15:41:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 329138 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 D66E42C00A4 for ; Wed, 12 Mar 2014 02:41:32 +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:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=xkocK8gD35slwWYeCIf1lNoYsxGyY F25/nWu33HlD9TeIMSFpzyRMB6qqBrL/ZZ9nxpjEpKDNuJex9Dhmvxz8ACZNFVym mynl+xbjMf9La6Iwo92+dhfZdvPdBudgKZ71Glayqbz+N4s/2C9U8OBwbNwWpyig 4jZJIg5xJ1jRWM= 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:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=vD24OHy3je6wuhthb7CL1BljzMU=; b=tUe Z9DcJE4q7HVMz2Jjb7aZDdiwUL/gLxUCuRthvRQJI70I22KteIQPJGg/1DjBeppr D0aZY+C5w0LacxdrhofgT8AyNPbqMZbLZ9MxONIdeC0Gq+G8C3EWnKOHA03FoYmx jkK1urIN4GcYEw51ySo5Q6nkleIaKly+XjZR7YEE= Received: (qmail 32301 invoked by alias); 11 Mar 2014 15:41:23 -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 32284 invoked by uid 89); 11 Mar 2014 15:41:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 11 Mar 2014 15:41:21 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2BFfFcu006141 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 11 Mar 2014 11:41:17 -0400 Received: from tucnak.zalov.cz (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s2BFfD63022144 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 11 Mar 2014 11:41:15 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.14.7/8.14.7) with ESMTP id s2BFf8bA001333; Tue, 11 Mar 2014 16:41:09 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.14.7/8.14.7/Submit) id s2BFf6RC001332; Tue, 11 Mar 2014 16:41:06 +0100 Date: Tue, 11 Mar 2014 16:41:05 +0100 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix __builtin_unreachable related regression (PR middle-end/60482) Message-ID: <20140311154105.GC22862@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Hi! As described in the PR, the r208165 change regressed following test. The problem is that VRP inserts a useless ASSERT_EXPR right before __builtin_unreachable () (obviously, the uses of the ASSERT_EXPR lhs aren't and can't be used by anything), which then prevents assert_unreachable_fallthru_edge_p from detecting it properly (but, even ignoring ASSERT_EXPRs there still would fail, because the ASSERT_EXPR adds another user of the SSA_NAME we check imm uses for). Perhaps FOUND_IN_SUBGRAPH (4.3 and earlier era) would be always true here, but live_on_edge provably isn't always true, so it makes sense to test it, something that isn't live on the edge is useless. The tree-cfg.c change is just small improvement discovered when looking into it, clobber stmts before __builtin_unreachable can be certainly ignored, they don't do anything. The patch regresses ssa-ifcombine-10.c testcase, I'll post a fix for that momentarily. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2014-03-11 Jakub Jelinek PR middle-end/60482 * tree-vrp.c (register_edge_assert_for_1): Don't add assert if there are multiple uses, but op doesn't live on E edge. * tree-cfg.c (assert_unreachable_fallthru_edge_p): Also ignore clobber stmts before __builtin_unreachable. * gcc.dg/vect/pr60482.c: New test. Jakub --- gcc/tree-vrp.c.jj 2014-01-25 00:11:37.000000000 +0100 +++ gcc/tree-vrp.c 2014-03-10 14:59:03.748267354 +0100 @@ -5423,12 +5423,9 @@ register_edge_assert_for_1 (tree op, enu return false; /* We know that OP will have a zero or nonzero value. If OP is used - more than once go ahead and register an assert for OP. - - The FOUND_IN_SUBGRAPH support is not helpful in this situation as - it will always be set for OP (because OP is used in a COND_EXPR in - the subgraph). */ - if (!has_single_use (op)) + more than once go ahead and register an assert for OP. */ + if (live_on_edge (e, op) + && !has_single_use (op)) { val = build_int_cst (TREE_TYPE (op), 0); register_new_assert_for (op, op, code, val, NULL, e, bsi); --- gcc/tree-cfg.c.jj 2014-02-20 21:38:42.000000000 +0100 +++ gcc/tree-cfg.c 2014-03-10 14:59:52.058957446 +0100 @@ -410,9 +410,9 @@ assert_unreachable_fallthru_edge_p (edge if (gsi_end_p (gsi)) return false; stmt = gsi_stmt (gsi); - if (is_gimple_debug (stmt)) + while (is_gimple_debug (stmt) || gimple_clobber_p (stmt)) { - gsi_next_nondebug (&gsi); + gsi_next (&gsi); if (gsi_end_p (gsi)) return false; stmt = gsi_stmt (gsi); --- gcc/testsuite/gcc.dg/vect/pr60482.c.jj 2014-03-10 15:08:16.700085976 +0100 +++ gcc/testsuite/gcc.dg/vect/pr60482.c 2014-03-10 15:15:09.609738455 +0100 @@ -0,0 +1,20 @@ +/* PR middle-end/60482 */ +/* { dg-do compile } */ +/* { dg-additional-options "-Ofast" } */ +/* { dg-require-effective-target vect_int } */ + +double +foo (double *x, int n) +{ + double p = 0.0; + int i; + x = __builtin_assume_aligned (x, 128); + if (n % 128) + __builtin_unreachable (); + for (i = 0; i < n; i++) + p += x[i]; + return p; +} + +/* { dg-final { scan-tree-dump-not "epilog loop required" "vect" } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */