From patchwork Tue Nov 1 13:58:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1697754 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.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=efs4qGUg; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4N1s780tLGz23l6 for ; Wed, 2 Nov 2022 00:58:28 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1BB613858418 for ; Tue, 1 Nov 2022 13:58:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1BB613858418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667311106; bh=inh2h0m6d29I9bep5/qICtCJNVDrMTi3p5613xqOpnQ=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=efs4qGUgC2+c30fNUu7DHLVRq9FOe6ppSPBsiAqAX9nxwrUXQ8Lww7Vq7XFpbsQ8V Ix9nn1bVPSMUgC49+QjUcFNgRHBIvtnSY0QUxBX4K9RkjCSrOzalqr640lFEJqWXqp fZ9VR9tcC8diYkef2N/q/AlVrgBjhwwqgDAfGAVc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 5884A3858D28 for ; Tue, 1 Nov 2022 13:58:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5884A3858D28 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-672-XcO4B_TrOISfpbZdy7_h2Q-1; Tue, 01 Nov 2022 09:58:04 -0400 X-MC-Unique: XcO4B_TrOISfpbZdy7_h2Q-1 Received: by mail-qt1-f197.google.com with SMTP id s14-20020a05622a1a8e00b00397eacd9c1aso9958917qtc.21 for ; Tue, 01 Nov 2022 06:58:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MRysbvzTyL1t6KSXKdd0E+E5kzY6Cztv9NQto6+G9Vk=; b=Hr6pATRHDPuq9uCBiAj7ByZ86QfZV/sV29CU0tVIS1Als7AS3f+0ew1nLh7aY5jWX1 RUZPidCcSfY35Lh0kjYA1oZV0jLUZHDBAqYdiFm7Dm7B9D2HijIP0Swkd9QFSeaiUrqh 2QniQbgpfYyiUU4ZBHytzSTyTSrri6B+WlFR33VgmJSpa7Uiz3PvhuA+P/uv5jTUiCkP rlwc6kwY/irxz254O/kbtTPPYefAxNos6sK8bzhMHUdU2pkd5EFCzekn2PINEy8EJfrl qHQV8VCNPi4ahQDOJnObgichzIvu4gQhNmGwPl7SEDpkLbKZunesvWi0o0Ey8AD6u02Y Su/A== X-Gm-Message-State: ACrzQf3LZszQMFFtfcDvVAa1epmt7yu+UOu517BPq8RExkwyS1oSyb53 +n5kU2/RjUcGYhxddvdrlsu4SMbslwqMRo7b66PSiFJQ9kW9SQQ/xJav1IetrLZWP99Ia9Wun2T 2PGIDAZPm7OBm3wIIeSxDmVCCp7Lb05x0m9yiWqK6skyOPgHHhQ3zwW4kKQUOyS8t5eFYJQ== X-Received: by 2002:ad4:5962:0:b0:4bb:6c2f:cbc2 with SMTP id eq2-20020ad45962000000b004bb6c2fcbc2mr16080356qvb.101.1667311082968; Tue, 01 Nov 2022 06:58:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM62zqs3pe5ajxiAFqUOOTxGyLJDSbZx1QKUuGlf9eUFL4mJgMAq50YMLgI+ciWNW4JQrD4erA== X-Received: by 2002:ad4:5962:0:b0:4bb:6c2f:cbc2 with SMTP id eq2-20020ad45962000000b004bb6c2fcbc2mr16080337qvb.101.1667311082678; Tue, 01 Nov 2022 06:58:02 -0700 (PDT) Received: from ?IPV6:2607:fea8:a263:f600::72c3? ([2607:fea8:a263:f600::72c3]) by smtp.gmail.com with ESMTPSA id n13-20020a05620a222d00b006fa12a74c53sm6488574qkh.61.2022.11.01.06.58.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Nov 2022 06:58:02 -0700 (PDT) Message-ID: <100da11f-424c-71e0-1275-f161b94ffa46@redhat.com> Date: Tue, 1 Nov 2022 09:58:00 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 To: gcc-patches Subject: [COMMITTED] Make ranger the vrp1 default. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Andrew MacLeod via Gcc-patches From: Andrew MacLeod Reply-To: Andrew MacLeod Cc: Jakub Jelinek Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This patch turns ranger on by default for the VRP1 pass. I needed to adjust gcc.dg/pr68217.c to scan for a better range ([-INF, -INF][0, 0]) than the original [-INF, 0] it was looking for. This also triggers the new __builtin_unreachable code in the ranger VRP pass, so I added a new testcase to show accumulated unreachables are combined properly.  tree-ssa/pr107009.c also verifies that a non-dominated unreachable call doesn't incorrectly affect the global range. Bootstrapped on x86_64-pc-linux-gnu with no regressions*. Pushed. * OK. no regressions is debatable.  I've been seeing the following spurious failure for the past few weeks.  Ranger made them pass for a while, then made them fail, so Ive been ignoring them. I took a quick look.  Basically, we optimize away an unnecessary statement feeding a condition based on a combination of what ranger calculates and results from loop analysis.  (The statement is not referenced in any debug statement).  That later causes a PHI to no longer been needed, and DCE2 removed the PHI and some other stuff, which then causes the debug_stmt to lose its reference.  /blame dce2 :-) < FAIL: gcc.dg/guality/pr54693-2.c   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  -DPREVENT_OPTIMIZATION line 21 x == 10 - i < FAIL: gcc.dg/guality/pr54693-2.c   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  -DPREVENT_OPTIMIZATION line 21 y == 20 - 2 * i < FAIL: gcc.dg/guality/pr54693-2.c   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  -DPREVENT_OPTIMIZATION line 21 z == 30 - 3 * i I choose to ignore this for now...  I want to get VRP1 turned to ranger by default and see if any issues show up.  I believe this removes the last remaining use of legacy vrp. Andrew commit e7310e24b1c0ca67b1bb507c1330b2bf39e59e32 Author: Andrew MacLeod Date: Tue Oct 25 16:42:41 2022 -0400 Make ranger vrp1 default. Turn on ranger as the default vrp1 pass and adjust testcases. gcc/ * params.opt (param_vrp1_mode): Make ranger default. gcc/testsuite/ * gcc.dg/pr68217.c: Test [-INF, -INF][0, 0] instead of [-INF, 0]. * gcc.dg/tree-ssa/vrp-unreachable.c: New. Test unreachable removal. diff --git a/gcc/params.opt b/gcc/params.opt index 3001566e641..a34fee193fc 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -1166,7 +1166,7 @@ Common Joined UInteger Var(param_vect_induction_float) Init(1) IntegerRage(0, 1) Enable loop vectorization of floating point inductions. -param=vrp1-mode= -Common Joined Var(param_vrp1_mode) Enum(vrp_mode) Init(VRP_MODE_VRP) Param Optimization +Common Joined Var(param_vrp1_mode) Enum(vrp_mode) Init(VRP_MODE_RANGER) Param Optimization --param=vrp1-mode=[vrp|ranger] Specifies the mode VRP1 should operate in. -param=vrp2-mode= diff --git a/gcc/testsuite/gcc.dg/pr68217.c b/gcc/testsuite/gcc.dg/pr68217.c index eb4f15e048f..60c80106760 100644 --- a/gcc/testsuite/gcc.dg/pr68217.c +++ b/gcc/testsuite/gcc.dg/pr68217.c @@ -10,4 +10,4 @@ int foo (void) return 0; } -/* { dg-final { scan-tree-dump "\\\[-INF, 0\\\]" "vrp1" } } */ +/* { dg-final { scan-tree-dump "\\\[-INF, -INF\\\]\\\[0, 0\\\]" "vrp1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp-unreachable.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp-unreachable.c new file mode 100644 index 00000000000..cdc57403c6e --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp-unreachable.c @@ -0,0 +1,42 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-vrp1-alias -fdump-tree-vrp2-alias" } */ + +void dead (unsigned n); +void alive (unsigned n); + +void func (unsigned n, unsigned m) +{ + if (n == 0) + __builtin_unreachable(); + if (n == 1) + __builtin_unreachable(); + if (n & 0x1) + __builtin_unreachable(); + if (n == 2) + __builtin_unreachable(); + if (n == 3) + __builtin_unreachable(); + if (n & 0x2) + __builtin_unreachable(); + if (n == 4) + __builtin_unreachable(); + if (n == 5) + __builtin_unreachable(); + if (n & 0x4) + __builtin_unreachable(); + if (n == 6) + __builtin_unreachable(); + if (n == 7) + __builtin_unreachable(); + if (n <8) + dead (n); + if (n != m) + __builtin_unreachable(); + alive (n); + alive (m); +} + +/* { dg-final { scan-tree-dump-not "dead" "vrp1" } } */ +/* { dg-final { scan-tree-dump-times "builtin_unreachable" 1 "vrp1" } } */ +/* { dg-final { scan-tree-dump-not "builtin_unreachable" "vrp2" } } */ +/* { dg-final { scan-tree-dump-times "fff8" 4 "vrp2" } } */