From patchwork Fri Jul 10 16:05:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1326958 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=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=SJ7is04G; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B3Hvl5qQtz9sRN for ; Sat, 11 Jul 2020 02:05:54 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 42A7D3840C3B; Fri, 10 Jul 2020 16:05:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 42A7D3840C3B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1594397151; bh=3Lz29UrNwIkS1Ic7c/2hEPwVnkbmGSYX6F/RyXhbXx0=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=SJ7is04GY8+xW3vEslyNbkxf4uaPtKuXQdB0aKzXEMkHXBhGLrXYxAKJ9lNaOqYgE 16t18QIHfdM7jCZYalJAD0z+dPQ51Y/LEQC8koaLn152yDgHrTeI+hkfLfyKIFWJrh tzRx41WpxpDvYtJI9Ei280Qgvj3umydaX+IIW/1I= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by sourceware.org (Postfix) with ESMTP id 394CC3842400 for ; Fri, 10 Jul 2020 16:05:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 394CC3842400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-141-wPc4OE5NN8-EiwqyNuURuA-1; Fri, 10 Jul 2020 12:05:39 -0400 X-MC-Unique: wPc4OE5NN8-EiwqyNuURuA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0F59A1083E85; Fri, 10 Jul 2020 16:05:38 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-112-218.ams2.redhat.com [10.36.112.218]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6A10070101; Fri, 10 Jul 2020 16:05:37 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id 06AG5WZh014593; Fri, 10 Jul 2020 18:05:33 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id 06AG5TVP014592; Fri, 10 Jul 2020 18:05:29 +0200 Date: Fri, 10 Jul 2020 18:05:29 +0200 To: Richard Biener , Jan Hubicka , Martin Jambor Subject: [PATCH] ipa-fnsummary: Fix ICE with switch predicates [PR96130] Message-ID: <20200710160529.GP2363@tucnak> MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi! The following testcase ICEs since r10-3199. There is a switch with default label, where the controlling expression has range just 0..7 and there are case labels for all those 8 values, but nothing has yet optimized away the default. Since r10-3199, set_switch_stmt_execution_predicate sets the switch to default label's edge's predicate to a false predicate and then compute_bb_predicates propagates the predicates through the cfg, but false predicates aren't really added. The caller of compute_bb_predicates in one place handles NULL bb->aux as false predicate: if (fbi.info) { if (bb->aux) bb_predicate = *(predicate *) bb->aux; else bb_predicate = false; } else bb_predicate = true; but then in two further spots that the patch below is changing it assumes bb->aux must be non-NULL. Those two spots are guarded by a condition that is only true if fbi.info is non-NULL, so I think the right fix is to treat NULL aux as false predicate in those spots too. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/10.2? 2020-07-10 Jakub Jelinek PR ipa/96130 * ipa-fnsummary.c (analyze_function_body): Treat NULL bb->aux as false predicate. * gcc.dg/torture/pr96130.c: New test. Jakub --- gcc/ipa-fnsummary.c.jj 2020-04-05 00:27:26.000000000 +0200 +++ gcc/ipa-fnsummary.c 2020-07-10 16:12:59.155168850 +0200 @@ -2766,7 +2766,10 @@ analyze_function_body (struct cgraph_nod edge ex; unsigned int j; class tree_niter_desc niter_desc; - bb_predicate = *(predicate *) loop->header->aux; + if (loop->header->aux) + bb_predicate = *(predicate *) loop->header->aux; + else + bb_predicate = false; exits = get_loop_exit_edges (loop); FOR_EACH_VEC_ELT (exits, j, ex) @@ -2799,7 +2802,10 @@ analyze_function_body (struct cgraph_nod for (unsigned i = 0; i < loop->num_nodes; i++) { gimple_stmt_iterator gsi; - bb_predicate = *(predicate *) body[i]->aux; + if (body[i]->aux) + bb_predicate = *(predicate *) body[i]->aux; + else + bb_predicate = false; for (gsi = gsi_start_bb (body[i]); !gsi_end_p (gsi); gsi_next (&gsi)) { --- gcc/testsuite/gcc.dg/torture/pr96130.c.jj 2020-07-10 16:15:28.794082127 +0200 +++ gcc/testsuite/gcc.dg/torture/pr96130.c 2020-07-10 16:14:49.273633241 +0200 @@ -0,0 +1,26 @@ +/* PR ipa/96130 */ +/* { dg-do compile } */ + +struct S { unsigned j : 3; }; +int k, l, m; + +void +foo (struct S x) +{ + while (l != 5) + switch (x.j) + { + case 1: + case 3: + case 4: + case 6: + case 2: + case 5: + l = m; + case 7: + case 0: + k = 0; + default: + break; + } +}