From patchwork Tue Dec 10 20:33:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1207268 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=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-515643-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="uXcaQeoA"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="L1m3sHXK"; 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 47XWxc1CLYz9sPK for ; Wed, 11 Dec 2019 07:34:10 +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:cc:subject:message-id:reply-to:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=NMY SYcI50kuhyBK2adLfroC0zazwerQhN+TArjgFquHceRUe9pV802wMsDJYEB4q2Tn yozWbmk2MkQbEatHsfPAHN0aCjKOGzRnNZ1rEcb1CkoFmfdpWWTV8Ql5GYA5bF4q BoaH1F/n/mxMC4X3TI74yWx3OS/n90hRySikyMPY= 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:content-transfer-encoding; s=default; bh=uZ2rVkTzQ TOYSxg+D5v45zo5m8s=; b=uXcaQeoAEr5qemXbvwsfVFej/9T3IgNPrZheO+d8D l9awDTp7c5TLSOqJyxOdfSTjjLpE5KUn8wx8Mp3rVkVORvnW44EwsJ3/T14b8uU2 Nxw0rHKM0YjrAViFfv2U7Ju1gwp1ksaemsui+UgJHWs8QBt5ZQY9TG9t12/HTY3+ J8= Received: (qmail 94721 invoked by alias); 10 Dec 2019 20:34:03 -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 94710 invoked by uid 89); 10 Dec 2019 20:34:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=hunk X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (207.211.31.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Dec 2019 20:34:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576010040; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PSTu7uOxi/+s+EmL0TMbJ93Vac78t1LGM3u7PBueVAc=; b=L1m3sHXKHy8ez+vS1AHfdEWTh9TUeeOEyMtsSI2dsKaKniQKLX5+E10DBtg1R7PMogcjTx 9i6S5eP00XarxP+DgX/JU0BAHH8ks7zYSja5DHWFXqqJ/bQ4QJTTOfuiZcVUFcDZAh+6g8 HyNGQiYmLAaLELkTGAFPgS3Q9fcmez8= 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-361-4pgi2BMvMuySnL-rkMIzrA-1; Tue, 10 Dec 2019 15:33:58 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9ED8810054E3; Tue, 10 Dec 2019 20:33:57 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-117-59.ams2.redhat.com [10.36.117.59]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 39FDE6A022; Tue, 10 Dec 2019 20:33:57 +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 xBAKXsZl006994; Tue, 10 Dec 2019 21:33:54 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id xBAKXpKx006993; Tue, 10 Dec 2019 21:33:51 +0100 Date: Tue, 10 Dec 2019 21:33:51 +0100 From: Jakub Jelinek To: Jan Hubicka , Martin Jambor , Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix propagate_vr_across_jump_function (PR ipa/92883) Message-ID: <20191210203351.GC10088@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Mimecast-Spam-Score: 0 Content-Disposition: inline X-IsSubscribed: yes Hi! The ipa vr hash table apparently intentionally doesn't differentiate between value ranges with different types, all that matters are the values of min and max, so before using it ipa_vr_operation_and_type_effects needs to be called to convert the value_range to the right type. Most of the spots do that correctly, but the second hunk fixes a spot that called it but ignored the newly computed value_range and used the non-converted one anyway. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2019-12-10 Jakub Jelinek PR ipa/92883 * ipa-cp.c (propagate_vr_across_jump_function): Pass jvr rather than *jfunc->m_vr to intersect. Formatting fix. * gcc.dg/ipa/pr92883.c: New test. Jakub --- gcc/ipa-cp.c.jj 2019-12-06 00:40:40.000000000 +0100 +++ gcc/ipa-cp.c 2019-12-10 11:57:10.354999085 +0100 @@ -2369,12 +2369,10 @@ propagate_vr_across_jump_function (cgrap value_range vr; if (TREE_CODE_CLASS (operation) == tcc_unary) - { - ipa_vr_operation_and_type_effects (&vr, - &src_lats->m_value_range.m_vr, - operation, param_type, - operand_type); - } + ipa_vr_operation_and_type_effects (&vr, + &src_lats->m_value_range.m_vr, + operation, param_type, + operand_type); /* A crude way to prevent unbounded number of value range updates in SCC components. We should allow limited number of updates within SCC, too. */ @@ -2400,7 +2398,7 @@ propagate_vr_across_jump_function (cgrap NOP_EXPR, param_type, jfunc->m_vr->type ())) - vr.intersect (*jfunc->m_vr); + vr.intersect (jvr); } return dest_lat->meet_with (&vr); } --- gcc/testsuite/gcc.dg/ipa/pr92883.c.jj 2019-12-10 12:45:49.260640164 +0100 +++ gcc/testsuite/gcc.dg/ipa/pr92883.c 2019-12-10 12:45:07.490278603 +0100 @@ -0,0 +1,14 @@ +/* PR ipa/92883 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int a, b, c, d; +unsigned e; +void baz (void *, int); +void grault (int, unsigned long); +int foo (unsigned g) { return a / g; } +void bar (void *g) { if (b) baz (g, 5); } +static void quux (int, unsigned long); +static void qux (unsigned long g) { if (g) { d = foo (-1); quux (e, (d & 2) + g); } } +static void quux (int g, unsigned long m) { (void) g; grault (c, m); bar (""); } +void corge () { qux (e); }